public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob) { if ($dbBatchJob->getJobType() == ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT)) { return true; } return false; }
public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob) { $jobTypes = array(ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE)); if (in_array($dbBatchJob->getJobType(), $jobTypes)) { return true; } return false; }
public function updatedJob(BatchJob $dbBatchJob) { $data = $dbBatchJob->getData(); if (!$data instanceof kDistributionJobData) { return true; } $doubleClickCoreValueType = kPluginableEnumsManager::apiToCore('DistributionProviderType', DoubleClickDistributionPlugin::getApiValue(DoubleClickDistributionProviderType::DOUBLECLICK)); if ($data->getProviderType() != $doubleClickCoreValueType) { return true; } if ($dbBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_PENDING) { return true; } $jobTypesToFinish = array(ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE)); if (in_array($dbBatchJob->getJobType(), $jobTypesToFinish)) { kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED); } return true; }
public function updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null) { $data = $dbBatchJob->getData(); if (!$data instanceof kDistributionJobData) { return true; } $attUverseCoreValueType = kPluginableEnumsManager::apiToCore('DistributionProviderType', AttUverseDistributionPlugin::getApiValue(AttUverseDistributionProviderType::ATT_UVERSE)); if ($data->getProviderType() != $attUverseCoreValueType) { return true; } $jobTypesToFinish = array(ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE)); if (in_array($dbBatchJob->getJobType(), $jobTypesToFinish) && $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FINISHED) { return self::onDistributionJobFinished($dbBatchJob, $data, $twinJob); } if ($dbBatchJob->getJobType() == ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE) && $dbBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_PENDING) { kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED); } return true; }
public function shouldConsumeJobStatusEvent(BatchJob $dbBatchJob) { $jobTypes = array(ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT), ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE)); if (!in_array($dbBatchJob->getJobType(), $jobTypes)) { // wrong job type return false; } $data = $dbBatchJob->getData(); if (!$data instanceof kDistributionJobData) { KalturaLog::err('Wrong job data type'); return false; } $crossKalturaCoreValueType = kPluginableEnumsManager::apiToCore('DistributionProviderType', CrossKalturaDistributionPlugin::getApiValue(CrossKalturaDistributionProviderType::CROSS_KALTURA)); if ($data->getProviderType() == $crossKalturaCoreValueType) { return true; } // not the right provider return false; }
/** * @action notify * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY * @param int $id distribution job id */ public function notifyAction($id) { $submitCoreType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT); $updateCoreType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE); $deleteCoreType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE); $validJobTypes = array($submitCoreType, $updateCoreType, $deleteCoreType); $batchJob = BatchJobPeer::retrieveByPK($id); $invalid = false; if (!$batchJob) { $invalid = true; KalturaLog::err("Job [{$id}] not found"); } elseif (!in_array($batchJob->getJobType(), $validJobTypes)) { $invalid = true; KalturaLog::err("Job [{$id}] wrong type [" . $batchJob->getJobType() . "] expected [" . implode(', ', $validJobTypes) . "]"); } elseif ($batchJob->getJobSubType() != UnicornDistributionProvider::get()->getType()) { $invalid = true; KalturaLog::err("Job [{$id}] wrong sub-type [" . $batchJob->getJobSubType() . "] expected [" . UnicornDistributionProvider::get()->getType() . "]"); } elseif ($batchJob->getStatus() != KalturaBatchJobStatus::ALMOST_DONE) { $invalid = true; KalturaLog::err("Job [{$id}] wrong status [" . $batchJob->getStatus() . "] expected [" . KalturaBatchJobStatus::ALMOST_DONE . "]"); } if ($invalid) { throw new KalturaAPIException(KalturaErrors::INVALID_BATCHJOB_ID, $id); } kJobsManager::updateBatchJob($batchJob, KalturaBatchJobStatus::FINISHED); $data = $batchJob->getData(); /* @var $data kDistributionJobData */ $providerData = $data->getProviderData(); /* @var $providerData kUnicornDistributionJobProviderData */ $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId()); if ($entryDistribution) { $entryDistribution->putInCustomData(kUnicornDistributionJobProviderData::CUSTOM_DATA_FLAVOR_ASSET_OLD_VERSION, $providerData->getFlavorAssetVersion()); $entryDistribution->save(); } if ($batchJob->getJobType() == $submitCoreType) { $this->attachRemoteAssetResource($batchJob->getEntry(), $batchJob->getData()); } if ($batchJob->getJobType() == $deleteCoreType) { $this->detachRemoteAssetResource($batchJob->getEntry(), $batchJob->getData()); } }
/** * batch getExclusiveAlmostDoneDistributionFetchReportJobs action allows to get a BatchJob of type DISTRIBUTION_FETCH_REPORT that wait for remote closure * * @action getExclusiveAlmostDoneDistributionFetchReportJobs * @param KalturaExclusiveLockKey $lockKey The unique lock key from the batch-process. Is used for the locking mechanism * @param int $maxExecutionTime The maximum time in seconds the job reguarly take. Is used for the locking mechanism when determining an unexpected termination of a batch-process. * @param int $numberOfJobs The maximum number of jobs to return. * @param KalturaBatchJobFilter $filter Set of rules to fetch only rartial list of jobs * @return KalturaBatchJobArray */ function getExclusiveAlmostDoneDistributionFetchReportJobsAction(KalturaExclusiveLockKey $lockKey, $maxExecutionTime, $numberOfJobs, KalturaBatchJobFilter $filter = null) { $jobType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT); return $this->getExclusiveAlmostDoneAction($lockKey, $maxExecutionTime, $numberOfJobs, $filter, $jobType); }
/** * @param EntryDistribution $entryDistribution * @param DistributionProfile $distributionProfile * @return BatchJob */ protected static function addSubmitDeleteJob(EntryDistribution $entryDistribution, DistributionProfile $distributionProfile) { $entryDistribution->setStatus(EntryDistributionStatus::DELETING); $entryDistribution->setDirtyStatus(null); if (!$entryDistribution->save()) { KalturaLog::err("Unable to save entry distribution [" . $entryDistribution->getId() . "] status"); return null; } $jobData = new kDistributionDeleteJobData(); $jobData->setDistributionProfileId($entryDistribution->getDistributionProfileId()); $jobData->setEntryDistributionId($entryDistribution->getId()); $jobData->setProviderType($distributionProfile->getProviderType()); $jobData->setRemoteId($entryDistribution->getRemoteId()); $jobData->setMediaFiles($entryDistribution->getMediaFiles()); $batchJob = new BatchJob(); $batchJob->setEntryId($entryDistribution->getEntryId()); $batchJob->setPartnerId($entryDistribution->getPartnerId()); $jobType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE); $jobSubType = $distributionProfile->getProviderType(); return kJobsManager::addJob($batchJob, $jobData, $jobType, $jobSubType); }
public function isLocalFileRequired($jobType) { if ($jobType == ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT)) { return true; } return false; }
public function updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null) { if ($dbBatchJob->getJobType() == ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_SUBMIT)) { self::onDistributionSubmitJobUpdated($dbBatchJob, $dbBatchJob->getData(), $twinJob); } if ($dbBatchJob->getJobType() == ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_UPDATE)) { self::onDistributionUpdateJobUpdated($dbBatchJob, $dbBatchJob->getData(), $twinJob); } if ($dbBatchJob->getJobType() == ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE)) { self::onDistributionDeleteJobUpdated($dbBatchJob, $dbBatchJob->getData(), $twinJob); } if ($dbBatchJob->getJobType() == ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_FETCH_REPORT)) { self::onDistributionFetchReportJobUpdated($dbBatchJob, $dbBatchJob->getData(), $twinJob); } if ($dbBatchJob->getJobType() == ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_ENABLE)) { self::onDistributionEnableJobUpdated($dbBatchJob, $dbBatchJob->getData(), $twinJob); } if ($dbBatchJob->getJobType() == ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DISABLE)) { self::onDistributionDisableJobUpdated($dbBatchJob, $dbBatchJob->getData(), $twinJob); } if ($dbBatchJob->getJobType() == BatchJobType::IMPORT) { self::onImportJobUpdated($dbBatchJob, $dbBatchJob->getData(), $twinJob); } return true; }
/** * @param EntryDistribution $entryDistribution * @param DistributionProfile $distributionProfile * @return BatchJob */ protected static function addSubmitDeleteJob(EntryDistribution $entryDistribution, DistributionProfile $distributionProfile) { $entryDistribution->setStatus(EntryDistributionStatus::DELETING); if (!$entryDistribution->save()) { KalturaLog::err("Unable to save entry distribution [" . $entryDistribution->getId() . "] status"); $entryDistribution->reload(); return null; } $entryDistribution->setDirtyStatus(null); //Moved down to ensure previous save is done Atomically $entryDistribution->save(); $jobData = new kDistributionDeleteJobData(); $jobData->setDistributionProfileId($entryDistribution->getDistributionProfileId()); $jobData->setEntryDistributionId($entryDistribution->getId()); $jobData->setProviderType($distributionProfile->getProviderType()); $jobData->setRemoteId($entryDistribution->getRemoteId()); $jobData->setMediaFiles($entryDistribution->getMediaFiles()); $batchJob = new BatchJob(); $batchJob->setEntryId($entryDistribution->getEntryId()); $batchJob->setPartnerId($entryDistribution->getPartnerId()); $batchJob->setObjectId($entryDistribution->getId()); $batchJob->setObjectType(kPluginableEnumsManager::apiToCore('BatchJobObjectType', ContentDistributionBatchJobObjectType::ENTRY_DISTRIBUTION)); $jobType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE); $jobSubType = $distributionProfile->getProviderType(); return kJobsManager::addJob($batchJob, $jobData, $jobType, $jobSubType); }
/** * @param EntryDistribution $entryDistribution * @param DistributionProfile $distributionProfile * @return BatchJob */ protected static function addSubmitDeleteJob(EntryDistribution $entryDistribution, DistributionProfile $distributionProfile) { $jobData = new kDistributionDeleteJobData(); $jobData->setDistributionProfileId($entryDistribution->getDistributionProfileId()); $jobData->setEntryDistributionId($entryDistribution->getId()); $jobData->setProviderType($distributionProfile->getProviderType()); $jobData->setRemoteId($entryDistribution->getRemoteId()); $batchJob = new BatchJob(); $batchJob->setEntryId($entryDistribution->getEntryId()); $batchJob->setPartnerId($entryDistribution->getPartnerId()); $jobType = ContentDistributionPlugin::getBatchJobTypeCoreValue(ContentDistributionBatchJobType::DISTRIBUTION_DELETE); $jobSubType = $distributionProfile->getProviderType(); return kJobsManager::addJob($batchJob, $jobData, $jobType, $jobSubType); }