当前位置: 首页>>代码示例>>PHP>>正文


PHP BatchJobPeer::postLockUpdate方法代码示例

本文整理汇总了PHP中BatchJobPeer::postLockUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP BatchJobPeer::postLockUpdate方法的具体用法?PHP BatchJobPeer::postLockUpdate怎么用?PHP BatchJobPeer::postLockUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BatchJobPeer的用法示例。


在下文中一共展示了BatchJobPeer::postLockUpdate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: lockObjects

 private static function lockObjects(kExclusiveLockKey $lockKey, array $objects, $max_execution_time)
 {
     $exclusive_objects_ids = array();
     // make sure the objects where not taken -
     $con = Propel::getConnection();
     $not_exclusive_count = 0;
     foreach ($objects as $object) {
         $lock_version = $object->getVersion();
         $criteria_for_exclusive_update = new Criteria();
         $criteria_for_exclusive_update->add(BatchJobLockPeer::ID, $object->getId());
         $criteria_for_exclusive_update->add(BatchJobLockPeer::VERSION, $lock_version);
         $update = new Criteria();
         // increment the lock_version - this will make sure it's exclusive
         $update->add(BatchJobLockPeer::VERSION, $lock_version + 1);
         // increment the execution_attempts
         $update->add(BatchJobLockPeer::EXECUTION_ATTEMPTS, $object->getExecutionAttempts() + 1);
         $update->add(BatchJobLockPeer::SCHEDULER_ID, $lockKey->getSchedulerId());
         $update->add(BatchJobLockPeer::WORKER_ID, $lockKey->getWorkerId());
         $update->add(BatchJobLockPeer::BATCH_INDEX, $lockKey->getBatchIndex());
         $expiration = time() + $max_execution_time;
         $update->add(BatchJobLockPeer::EXPIRATION, $expiration);
         $affectedRows = BasePeer::doUpdate($criteria_for_exclusive_update, $update, $con);
         KalturaLog::log("Lock update affected rows [{$affectedRows}] on job id [" . $object->getId() . "] lock version [{$lock_version}]");
         if ($affectedRows == 1) {
             // fix the object to reflect what is in the DB
             $object->setVersion($lock_version + 1);
             $object->setExecutionAttempts($object->getExecutionAttempts() + 1);
             $object->setSchedulerId($lockKey->getSchedulerId());
             $object->setWorkerId($lockKey->getWorkerId());
             $object->setBatchIndex($lockKey->getBatchIndex());
             $object->setExpiration($expiration);
             KalturaLog::log("Job id [" . $object->getId() . "] locked and returned");
             PartnerLoadPeer::updatePartnerLoad($object->getPartnerId(), $object->getJobType(), $object->getJobSubType(), $con);
             $exclusive_objects_ids[] = $object->getId();
         } else {
             $not_exclusive_count++;
             KalturaLog::log("Object not exclusive: [" . get_class($object) . "] id [" . $object->getId() . "]");
         }
     }
     return BatchJobPeer::postLockUpdate($lockKey, $exclusive_objects_ids, $con);
 }
开发者ID:DBezemer,项目名称:server,代码行数:41,代码来源:kBatchExclusiveLock.class.php


注:本文中的BatchJobPeer::postLockUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。