Пример #1
0
 /**
  * Checks whether sibling process and memory usage is within the constraints of a rule.
  *
  *
  * @param Rule  $rule
  * @param float $processor
  * @param float $memory
  *
  * @return bool
  */
 protected function withinSiblingConstraints(Rule $rule, $processor, $memory)
 {
     $minimumProcessor = 0;
     if ($rule->getMinimumSiblingProcessorUsage()) {
         $minimumProcessor = $rule->getMinimumSiblingProcessorUsage();
     }
     $maximumProcessor = 100;
     if ($rule->getMinimumSiblingProcessorUsage()) {
         $maximumProcessor = $rule->getMaximumSiblingProcessorUsage();
     }
     $minimumMemory = 0;
     if ($rule->getMinimumSiblingMemoryUsage()) {
         $minimumMemory = $rule->getMinimumSiblingMemoryUsage();
     }
     $maximumMemory = 100;
     if ($rule->getMinimumSiblingMemoryUsage()) {
         $maximumMemory = $rule->getMaximumSiblingMemoryUsage();
     }
     return $processor >= $minimumProcessor && $processor <= $maximumProcessor && $memory >= $minimumMemory && $memory <= $maximumMemory;
 }
Пример #2
0
 /**
  * Checks whether the profile or sibling processes is within the processor constraints of a
  * rule.
  *
  * @param Rule $rule
  * @param Profile $profile
  *
  * @return bool
  */
 private function withinSiblingProcessorConstraints(Rule $rule, Profile $profile)
 {
     if ($rule->getMinimumSiblingProcessorUsage() !== null && $rule->getMaximumSiblingProcessorUsage() !== null) {
         return $profile->getSiblingProcessorLoad() >= $rule->getMinimumSiblingProcessorUsage() && $profile->getSiblingProcessorLoad() <= $rule->getMaximumSiblingProcessorUsage();
     }
     return false;
 }