/** * @return boolean */ public function isConvertingSegments() { $criteria = new Criteria(); $criteria->add(BatchJobLockPeer::PARTNER_ID, $this->getPartnerId()); $criteria->add(BatchJobLockPeer::ENTRY_ID, $this->getId()); $criteria->add(BatchJobLockPeer::JOB_TYPE, BatchJobType::CONVERT_LIVE_SEGMENT); $criteria->add(BatchJobLockPeer::DC, kDataCenterMgr::getCurrentDcId()); $batchJob = BatchJobLockPeer::doSelectOne($criteria); if ($batchJob) { return true; } return false; }
public function resetFeaturesStatusByType($type) { $criteria = new Criteria(); $criteria->add(BatchJobLockPeer::PARTNER_ID, $this->getId()); $criteria->add(BatchJobLockPeer::JOB_TYPE, BatchJobType::INDEX); $criteria->add(BatchJobLockPeer::JOB_SUB_TYPE, $type); $batchJob = BatchJobLockPeer::doSelectOne($criteria); if ($batchJob) { $this->addFeaturesStatus($type); } else { $this->removeFeaturesStatus($type); } }
/** * * @param $id * @param kExclusiveLockKey db_lock_object * @param db_lock_objectstatus - optional. will be used to set the status once the object is free * @return BatchJob */ public static function freeExclusive($id, kExclusiveLockKey $lockKey, $resetExecutionAttempts = false) { $c = new Criteria(); $c->add(BatchJobLockPeer::ID, $id); $c->add(BatchJobLockPeer::SCHEDULER_ID, $lockKey->getSchedulerId()); $c->add(BatchJobLockPeer::WORKER_ID, $lockKey->getWorkerId()); $c->add(BatchJobLockPeer::BATCH_INDEX, $lockKey->getBatchIndex()); $db_lock_object = BatchJobLockPeer::doSelectOne($c); if (!$db_lock_object) { if (BatchJobLockPeer::retrieveByPK($id)) { throw new APIException(APIErrors::FREE_EXCLUSIVE_JOB_FAILED, $id, $lockKey->getSchedulerId(), $lockKey->getWorkerId(), $lockKey->getBatchIndex()); } else { return BatchJobPeer::retrieveByPK($id); } } $db_object = $db_lock_object->getBatchJob(); if ($resetExecutionAttempts || in_array($db_lock_object->getStatus(), BatchJobPeer::getClosedStatusList())) { $db_lock_object->setExecutionAttempts(0); } $db_lock_object->setSchedulerId(null); $db_lock_object->setWorkerId(null); $db_lock_object->setBatchIndex(null); $db_lock_object->setExpiration(null); $db_lock_object->save(); if ($db_object->getStatus() != BatchJob::BATCHJOB_STATUS_ABORTED && $db_object->getExecutionStatus() == BatchJobExecutionStatus::ABORTED) { $db_object = kJobsManager::abortDbBatchJob($db_object); } return $db_object; }
/** * batch resetJobExecutionAttempts action resets the execution attempts of the job * * @action resetJobExecutionAttempts * @param int $id The id of the job * @param KalturaExclusiveLockKey $lockKey The unique lock key from the batch-process. Is used for the locking mechanism * @param KalturaBatchJobType $jobType The type of the job * @throws KalturaErrors::UPDATE_EXCLUSIVE_JOB_FAILED * @throws KalturaErrors::UPDATE_EXCLUSIVE_JOB_WRONG_TYPE */ function resetJobExecutionAttemptsAction($id, KalturaExclusiveLockKey $lockKey, $jobType) { $jobType = kPluginableEnumsManager::apiToCore('BatchJobType', $jobType); $c = new Criteria(); $c->add(BatchJobLockPeer::ID, $id); $c->add(BatchJobLockPeer::SCHEDULER_ID, $lockKey->schedulerId); $c->add(BatchJobLockPeer::WORKER_ID, $lockKey->workerId); $c->add(BatchJobLockPeer::BATCH_INDEX, $lockKey->batchIndex); $job = BatchJobLockPeer::doSelectOne($c); if (!$job) { throw new KalturaAPIException(KalturaErrors::UPDATE_EXCLUSIVE_JOB_FAILED, $id, $lockKey->schedulerId, $lockKey->workerId, $lockKey->batchIndex); } // verifies that the job is of the right type if ($job->getJobType() != $jobType) { throw new KalturaAPIException(KalturaErrors::UPDATE_EXCLUSIVE_JOB_WRONG_TYPE, $id, $lockKey, null); } $job->setExecutionAttempts(0); $job->save(); }