Пример #1
0
 /**
  * Gets the load profile related to a task.
  *
  * @param Task $task
  * @param array $processes
  *
  * @return Profile
  */
 private function getProfileForProcesses(Task $task, array $processes)
 {
     $stats = $this->getStatsForProcesses($processes);
     $siblingProcesses = array_filter($processes, function (Task $next) use($task) {
         return $next->getHandler() === $task->getHandler();
     });
     $siblingStats = $this->getStatsForProcesses($siblingProcesses);
     $profile = $this->newProfile();
     $profile->setProcesses($processes);
     $profile->setProcessorLoad(min(100, array_sum(array_column($stats, 1))));
     $profile->setMemoryLoad(min(100, array_sum(array_column($stats, 2))));
     $profile->setSiblingProcesses($siblingProcesses);
     $profile->setSiblingProcessorLoad(min(100, array_sum(array_column($siblingStats, 1))));
     $profile->setSiblingMemoryLoad(min(100, array_sum(array_column($siblingStats, 2))));
     return $profile;
 }
Пример #2
0
 /**
  * Gets all the rules that apply to a task.
  *
  * @param Task $task
  *
  * @return Rule[]
  */
 private function getRulesForTask(Task $task)
 {
     return array_filter($this->rules, function (Rule $rule) use($task) {
         return $rule->getHandler() === null || $rule->getHandler() === $task->getHandler();
     });
 }
Пример #3
0
 /**
  * Gets the rules which apply to a task.
  *
  * @param Task $task
  *
  * @return array
  */
 protected function getRulesForTask(Task $task)
 {
     $rules = array();
     /** @var Rule $rule */
     foreach ($this->rules as $rule) {
         if ($rule->getHandler() === null || $rule->getHandler() === $task->getHandler()) {
             $rules[] = $rule;
         }
     }
     return $rules;
 }
Пример #4
0
 /**
  * @inheritdoc
  *
  * @return string
  */
 public function getHandler()
 {
     return $this->task->getHandler();
 }