本文整理汇总了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);
}