Exemple #1
0
 function startForking($workQueue)
 {
     if ($this->worker) {
         $this->worker->startForking($workQueue);
         $this->worker->enqueueWork($workQueue);
     }
 }
Exemple #2
0
 function startForking($workQueue)
 {
     $this->logger->debug("Start forking");
     //$this->processPool->on("signal", array($this, "onSignal"));
     //$this->processPool->on("shutdown", array($this, "onShutdown"));
     $this->worker->startForking($this->processPool->workQueue);
     if (!$this->nodeRegistry->nodesCapacity()) {
         $this->logger->info("Job is not running. Intiate job and begin leader election");
         // Create job znode
         $this->zookeeper->setOrCreate($this->jobZPath, null, false);
         // Create leader znode
         $this->zookeeper->setOrCreate("{$this->jobZPath}/leader", null, false);
         // Register node
         $this->nodeRegistry->set(self::REGKEY_MAIN_PROCESS_PID, posix_getpid());
         try {
             $this->leaderElection->initiate();
         } catch (Scalr_Service_Zookeeper_InterruptedException $ignore) {
         }
         $this->doLeaderElection();
         if ($this->isLeader) {
             $this->worker->enqueueWork($this->globalWorkQueue);
         }
     } else {
         $this->logger->info("Job is already running. Put myself into returned nodes queue");
         $this->nodeRegistry->set(self::REGKEY_MAIN_PROCESS_PID, posix_getpid());
         $this->returnedNodesQueue->put($this->elector->getElectionData());
     }
     $this->forkCoordinator();
     //return $this->processPool->workQueue;
 }