Ejemplo n.º 1
0
 protected function _flowPredict($flow)
 {
     if (count($this->_arrFlow) >= 18) {
         array_shift($this->_arrFlow);
     }
     array_push($this->_arrFlow, $flow);
     $average = ceil(array_sum($this->_arrFlow) / count($this->_arrFlow));
     $driveConf = $this->_objAha->getConfig()->get('aha', 'drive');
     $maxFlow = $driveConf['max_process_num'];
     if ($average > $maxFlow * 0.85) {
         \Daemon\Library\Ipc\Shared::getMaxTaskNumAtomic()->set(0);
         //根据流量预测 可能已经堵住了 清零自恢复
         Log::monitor()->error(array(Monitor::KEY => Monitor::FLOW_OVER_PREDICT_RESET, 'average' => $average, 'maxFlow' => $maxFlow * 0.85));
     }
     Log::statsLog()->debug(array('type' => 'flowPredict', 'average' => $average, 'maxFlow' => $maxFlow, 'point' => $maxFlow * 0.85));
     return $average;
 }
Ejemplo n.º 2
0
 protected function _taskWorkerComplete($package)
 {
     $pid = $package['content']['pid'];
     $res = \Daemon\Library\Ipc\Shared::getCurrentTaskTable()->decr($pid, 'taskNum', 1);
     if (false === $res) {
         Log::monitor()->error(array(Monitor::KEY => Monitor::TABLE_DECR_ERR, '#package' => $package));
     }
     $driveWorker = $this->_objManager->getDriveWorker();
     list($drivePid, $driveProcess) = each($driveWorker);
     $ret = $driveProcess->write(json_encode($package) . Constant::PACKAGE_EOF);
     if (false === $ret) {
         Log::monitor()->error(array(Monitor::KEY => Monitor::IPC_PIPE_WRITE_ERR, '#package' => $package));
         Log::redoLog(array('redo' => $package));
         return false;
     }
     Log::billLog()->debug(array('#package' => $package, 'type' => 'complete'));
     return true;
 }
Ejemplo n.º 3
0
 protected function _send($package)
 {
     $ret = $this->_worker->write(json_encode($package) . Constant::PACKAGE_EOF);
     if (false === $ret) {
         Log::monitor()->error(array(Monitor::KEY => Monitor::IPC_PIPE_WRITE_ERR, '%package' => $package));
         Log::redoLog()->debug(array('redo' => $package));
     } else {
         \Daemon\Library\Ipc\Shared::getMaxTaskNumAtomic()->add(1);
     }
     Log::billLog()->debug(array('%package' => $package, 'type' => 'send'));
 }
Ejemplo n.º 4
0
Archivo: Task.php Proyecto: eyehere/aha
 protected function _send($package)
 {
     $ret = $this->_worker->write(json_encode($package) . Constant::PACKAGE_EOF);
     if (false === $ret) {
         Log::monitor()->error(array(Monitor::KEY => Monitor::IPC_PIPE_WRITE_ERR, '^package' => $package));
         Log::redoLog()->debug(array('redo' => $package));
     }
     \Daemon\Library\Ipc\Shared::getMaxTaskNumAtomic()->sub(1);
     //在distribute进程减1有最短路径
     if (\Daemon\Library\Ipc\Shared::getMaxTaskNumAtomic()->get() > 2 << 16) {
         \Daemon\Library\Ipc\Shared::getMaxTaskNumAtomic()->set(0);
     }
     Log::billLog()->debug(array('^package' => $package, 'type' => '_distributeResponse'));
 }