Пример #1
0
 /**
  * TODO
  * @param \Billrun_Processor $processor
  * @return type
  */
 public function afterProcessorStore($processor)
 {
     if ($processor->getType() != "ggsn") {
         return;
     }
     Billrun_Factory::log('Plugin fraud afterProcessorStore', Zend_Log::INFO);
     $runAsync = Billrun_Factory::config()->getConfigValue('fraud.runAsync', 1);
     if (function_exists("pcntl_fork") && $runAsync && -1 !== ($pid = pcntl_fork())) {
         if ($pid == 0) {
             Billrun_Util::resetForkProcess();
             Billrun_Factory::log('Plugin fraud::afterProcessorStore run it in async mode', Zend_Log::INFO);
             $this->insertRoamingGgsn($processor->getData()['data']);
             Billrun_Factory::log('Plugin fraud::afterProcessorStore async mode done.', Zend_Log::INFO);
             exit;
             // exit from child process after finish
         }
     } else {
         Billrun_Factory::log('Plugin fraud::afterProcessorStore runing in sync mode', Zend_Log::INFO);
         $this->insertRoamingGgsn($processor->getData()['data']);
     }
     Billrun_Factory::log('Plugin fraud afterProcessorStore was ended', Zend_Log::INFO);
 }
Пример #2
0
 /**
  * extend the customer aggregator to generate the invoice right after the aggregator finished. EXPERIMENTAL feature.
  * 
  * @param int                 $accid account id
  * @param account             $account account subscribers details
  * @param Billrun_Billrun     $account_billrun the billrun data of the account
  * @param array               $lines the lines that was aggregated
  * @param Billrun_Aggregator  $aggregator the aggregator class that fired the event
  * 
  * @return void
  */
 public function afterAggregateAccount($accid, $account, Billrun_Billrun $account_billrun, $lines, Billrun_Aggregator $aggregator)
 {
     $forkXmlGeneration = Billrun_Factory::config()->getConfigValue('calcCpu.forkXmlGeneration', 0);
     if ($forkXmlGeneration && function_exists("pcntl_fork")) {
         $forkXmlLimit = Billrun_Factory::config()->getConfigValue('calcCpu.forkXmlLimit', 100);
         if ($this->childProcesses > $forkXmlLimit) {
             Billrun_Factory::log('Plugin calc cpu afterAggregateAccount : Releasing Zombies...', Zend_Log::INFO);
             $this->releaseZombies($forkXmlLimit);
         }
         if ($this->childProcesses <= $forkXmlLimit) {
             if (-1 !== ($pid = pcntl_fork())) {
                 if ($pid == 0) {
                     Billrun_Util::resetForkProcess();
                     Billrun_Factory::log('Plugin calc cpu afterAggregateAccount run it in async mode', Zend_Log::INFO);
                     $this->makeXml($account_billrun, $lines);
                     exit(0);
                     // exit from child process after finish creating xml; continue on parent
                 }
                 $this->childProcesses++;
                 Billrun_Factory::log('Plugin calc cpu afterAggregateAccount forked the xml generation. Continue to next account', Zend_Log::INFO);
                 return;
             }
         }
     }
     Billrun_Factory::log('Plugin calc cpu afterAggregateAccount run it in sync mode', Zend_Log::INFO);
     $this->makeXml($account_billrun, $lines);
 }