本文整理汇总了PHP中kJobsManager::updateBatchJob方法的典型用法代码示例。如果您正苦于以下问题:PHP kJobsManager::updateBatchJob方法的具体用法?PHP kJobsManager::updateBatchJob怎么用?PHP kJobsManager::updateBatchJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kJobsManager
的用法示例。
在下文中一共展示了kJobsManager::updateBatchJob方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notifyAction
/**
* @action notify
* @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
* @param int $id integration job id
*/
public function notifyAction($id)
{
$coreType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION);
$batchJob = BatchJobPeer::retrieveByPK($id);
$invalidJobId = false;
$invalidKs = false;
if (!self::validateKs($batchJob)) {
$invalidKs = true;
KalturaLog::err("ks not valid for notifying job [{$id}]");
} elseif (!$batchJob) {
$invalidJobId = true;
KalturaLog::err("Job [{$id}] not found");
} elseif ($batchJob->getJobType() != $coreType) {
$invalidJobId = true;
KalturaLog::err("Job [{$id}] wrong type [" . $batchJob->getJobType() . "] expected [" . $coreType . "]");
} elseif ($batchJob->getStatus() != KalturaBatchJobStatus::ALMOST_DONE) {
$invalidJobId = true;
KalturaLog::err("Job [{$id}] wrong status [" . $batchJob->getStatus() . "] expected [" . KalturaBatchJobStatus::ALMOST_DONE . "]");
} elseif ($batchJob->getPartnerId() != kCurrentContext::getCurrentPartnerId()) {
$invalidKs = true;
KalturaLog::err("Job [{$id}] of wrong partner [" . $batchJob->getPartnerId() . "] expected [" . kCurrentContext::getCurrentPartnerId() . "]");
}
if ($invalidJobId) {
throw new KalturaAPIException(KalturaErrors::INVALID_BATCHJOB_ID, $id);
}
if ($invalidKs) {
throw new KalturaAPIException(KalturaIntegrationErrors::INTEGRATION_NOTIFY_FAILED);
}
kJobsManager::updateBatchJob($batchJob, KalturaBatchJobStatus::FINISHED);
}
示例2: updatedJob
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;
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:19,代码来源:kAttUverseDistributionEventConsumer.php
示例3: updatedJob
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;
}
示例4: notifyAction
/**
* @action notify
* @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY
* @param int $id integration job id
*/
public function notifyAction($id)
{
$coreType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION);
$batchJob = BatchJobPeer::retrieveByPK($id);
$invalid = false;
if (!$batchJob) {
$invalid = true;
KalturaLog::err("Job [{$id}] not found");
} elseif ($batchJob->getJobType() != $coreType) {
$invalid = true;
KalturaLog::err("Job [{$id}] wrong type [" . $batchJob->getJobType() . "] expected [" . $coreType . "]");
} 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);
}
示例5: addintegrationJob
public static function addintegrationJob($objectType, $objectId, kIntegrationJobData $data)
{
$partnerId = kCurrentContext::getCurrentPartnerId();
$batchJob = new BatchJob();
$batchJob->setPartnerId($partnerId);
$batchJob->setObjectType($objectType);
$batchJob->setObjectId($objectId);
if ($objectType == BatchJobObjectType::ENTRY) {
$batchJob->setEntryId($objectId);
} elseif ($objectType == BatchJobObjectType::ASSET) {
$asset = assetPeer::retrieveById($objectId);
if ($asset) {
$batchJob->setEntryId($asset->getEntryId());
}
}
$batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
$jobType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION);
$batchJob = kJobsManager::addJob($batchJob, $data, $jobType, $data->getProviderType());
return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
}
示例6: notifyAction
/**
* @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());
}
}
示例7: addEventNotificationDispatchJob
/**
* @param int $eventNotificationType
* @param kEventNotificationDispatchJobData $jobData
* @param string $partnerId
* @param string $entryId
* @param BatchJob $parentJob
* @return BatchJob
*/
protected function addEventNotificationDispatchJob($eventNotificationType, kEventNotificationDispatchJobData $jobData, $partnerId = null, $entryId = null, BatchJob $parentJob = null)
{
$jobType = EventNotificationPlugin::getBatchJobTypeCoreValue(EventNotificationBatchType::EVENT_NOTIFICATION_HANDLER);
$batchJob = null;
if ($parentJob) {
$batchJob = $parentJob->createChild($jobType, $eventNotificationType, false);
} else {
$batchJob = new BatchJob();
$batchJob->setEntryId($entryId);
if (!$partnerId) {
$partnerId = kCurrentContext::getCurrentPartnerId();
}
$batchJob->setPartnerId($partnerId);
}
KalturaLog::log("Creating event notification dispatch job on template id [" . $jobData->getTemplateId() . "] engine[{$eventNotificationType}]");
$batchJob->setObjectId($entryId);
$batchJob->setObjectType(BatchJobObjectType::ENTRY);
$batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
$batchJob = kJobsManager::addJob($batchJob, $jobData, $jobType, $eventNotificationType);
$jobData->setJobId($batchJob->getId());
$batchJob->setData($jobData);
return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
}
示例8: updatedJob
public function updatedJob(BatchJob $dbBatchJob, BatchJob $twinJob = null)
{
if ($dbBatchJob->getStatus() != BatchJob::BATCHJOB_STATUS_PENDING) {
return true;
}
if ($dbBatchJob->getJobType() == BatchJobType::PROVISION_PROVIDE) {
$entry = $dbBatchJob->getEntry(false, false);
$partner = $entry->getPartner();
$limeLightLiveParamsJSON = $partner->getLiveStreamProvisionParams();
$limeLightLiveParams = json_decode($limeLightLiveParamsJSON);
if (!isset($limeLightLiveParams->Limelight) || !isset($limeLightLiveParams->Limelight->limelightPrimaryPublishUrl) || !isset($limeLightLiveParams->Limelight->limelightSecondaryPublishUrl) || !isset($limeLightLiveParams->Limelight->limelightStreamUrl)) {
kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FAILED);
return true;
}
$data = $dbBatchJob->getData();
$data->setPrimaryBroadcastingUrl($limeLightLiveParams->Limelight->limelightPrimaryPublishUrl);
$data->setSecondaryBroadcastingUrl($limeLightLiveParams->Limelight->limelightSecondaryPublishUrl);
$data->setRtmp($limeLightLiveParams->Limelight->limelightStreamUrl);
$data->setStreamName($entry->getId() . '_%i');
$dbBatchJob->setData($data);
}
kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED);
return true;
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:24,代码来源:kLimeLightLiveFlowManager.php
示例9: addintegrationJob
public static function addintegrationJob($objectType, $objectId, kIntegrationJobData $data)
{
$partnerId = kCurrentContext::getCurrentPartnerId();
$providerType = $data->getProviderType();
$integrationProvider = KalturaPluginManager::loadObject('IIntegrationProvider', $providerType);
if (!$integrationProvider || !$integrationProvider->validatePermissions($partnerId)) {
KalturaLog::err("partner {$partnerId} not permitted with provider type {$providerType}");
return false;
}
$batchJob = new BatchJob();
$batchJob->setPartnerId($partnerId);
$batchJob->setObjectType($objectType);
$batchJob->setObjectId($objectId);
if ($objectType == BatchJobObjectType::ENTRY) {
$batchJob->setEntryId($objectId);
} elseif ($objectType == BatchJobObjectType::ASSET) {
$asset = assetPeer::retrieveById($objectId);
if ($asset) {
$batchJob->setEntryId($asset->getEntryId());
}
}
$batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
$jobType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION);
$batchJob = kJobsManager::addJob($batchJob, $data, $jobType, $providerType);
if ($integrationProvider->shouldSendCallBack()) {
$jobId = $batchJob->getId();
$ks = self::generateKs($partnerId, $jobId);
$callBackUrl = "http://" . kConf::get('cdn_api_host');
$callBackUrl .= "/api_v3/index.php/service/integration_integration/action/notify";
$callBackUrl .= "/id/{$jobId}/ks/{$ks}";
$data = $batchJob->getData();
$data->setCallbackNotificationUrl($callBackUrl);
$batchJob->setData($data);
}
return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
}
示例10: onDistributionDeleteJobPending
/**
* @param BatchJob $dbBatchJob
* @param kDistributionDeleteJobData $data
* @param BatchJob $twinJob
* @return BatchJob
*/
public static function onDistributionDeleteJobPending(BatchJob $dbBatchJob, kDistributionDeleteJobData $data, BatchJob $twinJob = null)
{
if ($data->getProviderType() == DistributionProviderType::SYNDICATION) {
$dbBatchJob = kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED);
}
return $dbBatchJob;
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:13,代码来源:kContentDistributionFlowManager.php
示例11: handleConvertFinished
/**
* @param BatchJob $dbBatchJob
* @param flavorAsset $currentFlavorAsset
* @return BatchJob
*/
public static function handleConvertFinished(BatchJob $dbBatchJob = null, flavorAsset $currentFlavorAsset)
{
KalturaLog::debug("entry id [" . $currentFlavorAsset->getEntryId() . "] flavor asset id [" . $currentFlavorAsset->getId() . "]");
$profile = null;
try {
$profile = myPartnerUtils::getConversionProfile2ForEntry($currentFlavorAsset->getEntryId());
KalturaLog::debug("profile [" . $profile->getId() . "]");
} catch (Exception $e) {
KalturaLog::err($e->getMessage());
}
$currentReadyBehavior = self::getReadyBehavior($currentFlavorAsset, $profile);
KalturaLog::debug("Current ready behavior [{$currentReadyBehavior}]");
if ($currentReadyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_IGNORE) {
return $dbBatchJob;
}
$rootBatchJob = null;
if ($dbBatchJob) {
$rootBatchJob = $dbBatchJob->getRootJob();
}
if ($rootBatchJob) {
KalturaLog::debug("root batch job id [" . $rootBatchJob->getId() . "] type [" . $rootBatchJob->getJobType() . "]");
}
// update the root job end exit
if ($rootBatchJob && $rootBatchJob->getJobType() == BatchJobType::BULKDOWNLOAD) {
$siblingJobs = $rootBatchJob->getChildJobs();
foreach ($siblingJobs as $siblingJob) {
// checking only conversion child jobs
if ($siblingJob->getJobType() != BatchJobType::CONVERT && $siblingJob->getJobType() != BatchJobType::CONVERT_COLLECTION && $siblingJob->getJobType() != BatchJobType::POSTCONVERT) {
continue;
}
// if not complete leave function
if (!in_array($siblingJob->getStatus(), BatchJobPeer::getClosedStatusList())) {
KalturaLog::debug("job id [" . $siblingJob->getId() . "] status [" . $siblingJob->getStatus() . "]");
return $dbBatchJob;
}
}
KalturaLog::debug("finish bulk download root job");
// all child jobs completed
kJobsManager::updateBatchJob($rootBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED);
return $dbBatchJob;
}
$inheritedFlavorParamsIds = array();
$requiredFlavorParamsIds = array();
$flavorParamsConversionProfileItems = array();
if ($profile) {
$flavorParamsConversionProfileItems = flavorParamsConversionProfilePeer::retrieveByConversionProfile($profile->getId());
}
foreach ($flavorParamsConversionProfileItems as $flavorParamsConversionProfile) {
if ($flavorParamsConversionProfile->getReadyBehavior() == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) {
$requiredFlavorParamsIds[$flavorParamsConversionProfile->getFlavorParamsId()] = true;
}
if ($flavorParamsConversionProfile->getReadyBehavior() == flavorParamsConversionProfile::READY_BEHAVIOR_NO_IMPACT) {
$inheritedFlavorParamsIds[] = $flavorParamsConversionProfile->getFlavorParamsId();
}
}
$flavorParamsItems = assetParamsPeer::retrieveByPKs($inheritedFlavorParamsIds);
foreach ($flavorParamsItems as $flavorParams) {
if ($flavorParams->getReadyBehavior() == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) {
$requiredFlavorParamsIds[$flavorParamsConversionProfile->getFlavorParamsId()] = true;
}
}
KalturaLog::debug("required flavor params ids [" . print_r($requiredFlavorParamsIds, true) . "]");
// go over all the flavor assets of the entry
$inCompleteFlavorIds = array();
$origianlAssetFlavorId = null;
$siblingFlavorAssets = assetPeer::retrieveFlavorsByEntryId($currentFlavorAsset->getEntryId());
foreach ($siblingFlavorAssets as $siblingFlavorAsset) {
KalturaLog::debug("sibling flavor asset id [" . $siblingFlavorAsset->getId() . "] flavor params id [" . $siblingFlavorAsset->getFlavorParamsId() . "]");
// don't mark any incomplete flag
if ($siblingFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
KalturaLog::debug("sibling flavor asset id [" . $siblingFlavorAsset->getId() . "] is ready");
if (isset($requiredFlavorParamsIds[$siblingFlavorAsset->getFlavorParamsId()])) {
unset($requiredFlavorParamsIds[$siblingFlavorAsset->getFlavorParamsId()]);
}
continue;
}
$readyBehavior = self::getReadyBehavior($siblingFlavorAsset, $profile);
if ($siblingFlavorAsset->getStatus() == flavorAsset::ASSET_STATUS_EXPORTING) {
if ($siblingFlavorAsset->getIsOriginal()) {
$origianlAssetFlavorId = $siblingFlavorAsset->getFlavorParamsId();
} else {
if ($readyBehavior != flavorParamsConversionProfile::READY_BEHAVIOR_IGNORE) {
KalturaLog::debug("sibling flavor asset id [" . $siblingFlavorAsset->getId() . "] is incomplete");
$inCompleteFlavorIds[] = $siblingFlavorAsset->getFlavorParamsId();
}
}
}
if ($readyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_IGNORE) {
KalturaLog::debug("sibling flavor asset id [" . $siblingFlavorAsset->getId() . "] is ignored");
continue;
}
if ($siblingFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_QUEUED || $siblingFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_CONVERTING || $siblingFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_IMPORTING || $siblingFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_VALIDATING) {
KalturaLog::debug("sibling flavor asset id [" . $siblingFlavorAsset->getId() . "] is incomplete");
$inCompleteFlavorIds[] = $siblingFlavorAsset->getFlavorParamsId();
}
//.........这里部分代码省略.........
示例12: decideSourceFlavorConvert
private static function decideSourceFlavorConvert($entryId, assetParams $sourceFlavor = null, flavorAsset $originalFlavorAsset, $conversionProfileId, $flavors, mediaInfo $mediaInfo = null, BatchJob $parentJob, BatchJob $convertProfileJob)
{
if ($sourceFlavor && ($sourceFlavor->getOperators() || $sourceFlavor->getConversionEngines()) && $originalFlavorAsset->getInterFlowCount() == null) {
KalturaLog::log("Source flavor asset requires conversion");
self::adjustAssetParams($entryId, array($sourceFlavor));
$srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$errDescription = null;
$sourceFlavorOutput = self::validateFlavorAndMediaInfo($sourceFlavor, $mediaInfo, $errDescription);
if (!$sourceFlavorOutput) {
if (!$errDescription) {
$errDescription = "Failed to create flavor params output from source flavor";
}
$originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
$originalFlavorAsset->setStatus(flavorAsset::ASSET_STATUS_ERROR);
$originalFlavorAsset->save();
kBatchManager::updateEntry($entryId, entryStatus::ERROR_CONVERTING);
kJobsManager::updateBatchJob($convertProfileJob, BatchJob::BATCHJOB_STATUS_FAILED);
return false;
}
} elseif ($mediaInfo) {
/*
* Check whether there is a need for an intermediate source pre-processing
*/
$sourceFlavorOutput = KDLWrap::GenerateIntermediateSource($mediaInfo, $flavors);
if (!$sourceFlavorOutput) {
return true;
}
$srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$errDescription = null;
/*
* Save the original source asset in another asset, in order
* to prevent its liquidated by the inter-source asset.
* But, do it only if the conversion profile contains source flavor
*/
if ($sourceFlavor) {
$sourceAsset = assetPeer::retrieveById($mediaInfo->getFlavorAssetId());
$copyFlavorParams = assetParamsPeer::retrieveBySystemName(self::SAVE_ORIGINAL_SOURCE_FLAVOR_PARAM_SYS_NAME);
if (!$copyFlavorParams) {
throw new APIException(APIErrors::OBJECT_NOT_FOUND);
}
$asset = $sourceAsset->copy();
$asset->setFlavorParamsId($copyFlavorParams->getId());
$asset->setFromAssetParams($copyFlavorParams);
$asset->setStatus(flavorAsset::ASSET_STATUS_READY);
$asset->setIsOriginal(0);
$asset->setTags($copyFlavorParams->getTags());
$asset->incrementVersion();
$asset->save();
kFileSyncUtils::createSyncFileLinkForKey($asset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET), $sourceAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET));
$origFileSync = kFileSyncUtils::getLocalFileSyncForKey($sourceAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET));
$asset->setSize(intval($origFileSync->getFileSize() / 1000));
$asset->save();
}
}
/*
* '_passthrough' controls whether the source is to be 'passthrough' although there
* is a source flavor that contains transcoder settings.
* Looks for a '_passthrough' flag on the source's flavor params output.
*/
if (!$sourceFlavorOutput || $sourceFlavorOutput->_passthrough == true) {
return true;
}
// save flavor params
$sourceFlavorOutput->setPartnerId($sourceFlavorOutput->getPartnerId());
$sourceFlavorOutput->setEntryId($entryId);
$sourceFlavorOutput->setFlavorAssetId($originalFlavorAsset->getId());
$sourceFlavorOutput->setFlavorAssetVersion($originalFlavorAsset->getVersion());
$sourceFlavorOutput->save();
if ($errDescription) {
$originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
}
$errDescription = kBusinessConvertDL::parseFlavorDescription($sourceFlavorOutput);
if ($errDescription) {
$originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
}
// decided by the business logic layer
if ($sourceFlavorOutput->_create_anyway) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] selected to be created anyway");
} else {
if (!$sourceFlavorOutput->IsValid()) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is invalid");
$originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$originalFlavorAsset->save();
$errDescription = "Source flavor could not be converted";
self::setError($errDescription, $convertProfileJob, BatchJobType::CONVERT_PROFILE, $convertProfileJob->getEntryId());
return false;
}
if ($sourceFlavorOutput->_force) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is forced");
} elseif ($sourceFlavorOutput->_isNonComply) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is none-comply");
} else {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is valid");
}
}
$originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_CONVERTING);
if (isset($sourceFlavor)) {
$originalFlavorAsset->addTags($sourceFlavor->getTagsArray());
$originalFlavorAsset->setFileExt($sourceFlavorOutput->getFileExt());
$originalFlavorAsset->save();
//.........这里部分代码省略.........
示例13: addBulkUploadJob
/**
* Function adds bulk upload job to the queue
* @param Partner $partner
* @param kBulkUploadJobData $jobData
* @param string $bulkUploadType
* @throws APIException
* @return BatchJob
*/
public static function addBulkUploadJob(Partner $partner, kBulkUploadJobData $jobData, $bulkUploadType = null, $objectId = null, $objectType = null)
{
KalturaLog::debug("adding BulkUpload job");
$job = new BatchJob();
$job->setPartnerId($partner->getId());
$job->setJobType(BatchJobType::BULKUPLOAD);
$job->setJobSubType($bulkUploadType);
if (!is_null($objectId) && !is_null($objectType)) {
$job->setObjectId($objectId);
$job->setObjectType($objectType);
}
if (is_null($jobData)) {
throw new APIException(APIErrors::BULK_UPLOAD_BULK_UPLOAD_TYPE_NOT_VALID, $bulkUploadType);
}
$job->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
$job = kJobsManager::addJob($job, $jobData, BatchJobType::BULKUPLOAD, $bulkUploadType);
if (!is_null($jobData->getFilePath())) {
$syncKey = $job->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOAD);
// kFileSyncUtils::file_put_contents($syncKey, file_get_contents($csvFileData["tmp_name"]));
try {
kFileSyncUtils::moveFromFile($jobData->getFilePath(), $syncKey, true);
} catch (Exception $e) {
KalturaLog::err($e);
throw new APIException(APIErrors::BULK_UPLOAD_CREATE_CSV_FILE_SYNC_ERROR);
}
$filePath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
$jobData->setFilePath($filePath);
}
if (!$jobData->getBulkUploadObjectType()) {
$jobData->setBulkUploadObjectType(BulkUploadObjectType::ENTRY);
}
if ($jobData->getBulkUploadObjectType() == BulkUploadObjectType::ENTRY && !$jobData->getObjectData()->getConversionProfileId()) {
$jobData->setConversionProfileId($partner->getDefaultConversionProfileId());
$kmcVersion = $partner->getKmcVersion();
$check = null;
if ($kmcVersion < 2) {
$check = ConversionProfilePeer::retrieveByPK($jobData->getConversionProfileId());
} else {
$check = conversionProfile2Peer::retrieveByPK($jobData->getConversionProfileId());
}
if (!$check) {
throw new APIException(APIErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $jobData->getConversionProfileId());
}
}
$job->setData($jobData);
return kJobsManager::updateBatchJob($job, BatchJob::BATCHJOB_STATUS_PENDING);
}
示例14: cleanExclusiveJobs
public static function cleanExclusiveJobs()
{
$jobs = kBatchExclusiveLock::getExpiredJobs();
foreach ($jobs as $job) {
KalturaLog::log("Cleaning job id[" . $job->getId() . "]");
kJobsManager::updateBatchJob($job, BatchJob::BATCHJOB_STATUS_FATAL);
}
$c = new Criteria();
$c->add(BatchJobPeer::STATUS, BatchJobPeer::getClosedStatusList(), Criteria::IN);
$c->add(BatchJobPeer::BATCH_INDEX, null, Criteria::ISNOTNULL);
// The 'closed' jobs should be donn for at least 10min.
// before the cleanup starts messing upo with'em
// This solves cases when job (convert) completes succesfully,
// but the next job (closure)does not get a chance to take over due to the clean-up
$c->add(BatchJobPeer::FINISH_TIME, time() - 600, Criteria::LESS_THAN);
// MUST be the master DB
$jobs = BatchJobPeer::doSelect($c, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
foreach ($jobs as $job) {
KalturaLog::log("Cleaning job id[" . $job->getId() . "]");
$job->setSchedulerId(null);
$job->setWorkerId(null);
$job->setBatchIndex(null);
$job->setProcessorExpiration(null);
$job->save();
}
return count($jobs);
}
示例15: decideSourceFlavorConvert
private static function decideSourceFlavorConvert($entryId, assetParams $sourceFlavor = null, flavorAsset $originalFlavorAsset, $conversionProfileId, $flavors, mediaInfo $mediaInfo = null, BatchJob $parentJob, BatchJob $convertProfileJob)
{
if ($sourceFlavor && ($sourceFlavor->getOperators() || $sourceFlavor->getConversionEngines()) && $originalFlavorAsset->getInterFlowCount() == null) {
KalturaLog::log("Source flavor asset requires conversion");
self::adjustAssetParams($entryId, array($sourceFlavor));
$srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$errDescription = null;
$sourceFlavorOutput = self::validateFlavorAndMediaInfo($sourceFlavor, $mediaInfo, $errDescription);
if (!$sourceFlavorOutput) {
if (!$errDescription) {
$errDescription = "Failed to create flavor params output from source flavor";
}
$originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
$originalFlavorAsset->setStatus(flavorAsset::ASSET_STATUS_ERROR);
$originalFlavorAsset->save();
kBatchManager::updateEntry($entryId, entryStatus::ERROR_CONVERTING);
kJobsManager::updateBatchJob($convertProfileJob, BatchJob::BATCHJOB_STATUS_FAILED);
return false;
}
/*
* If the conversion profile contains source flavor and the source is tagged with 'save_source' ==>
* save the original source asset in another asset, in order
* to prevent its liquidated by the inter-source asset.
*/
if (isset($sourceFlavor) && strstr($sourceFlavor->getTagsArray(), assetParams::TAG_SAVE_SOURCE) !== false) {
self::saveOriginalSource($mediaInfo);
}
} elseif ($mediaInfo) {
/*
* Check whether there is a need for an intermediate source pre-processing
*/
$sourceFlavorOutput = KDLWrap::GenerateIntermediateSource($mediaInfo, $flavors);
if (!$sourceFlavorOutput) {
return true;
}
$srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$errDescription = null;
/*
* Save the original source asset in another asset, in order
* to prevent its liquidated by the inter-source asset.
* But, do it only if the conversion profile contains source flavor
*/
if (isset($sourceFlavor)) {
self::saveOriginalSource($mediaInfo);
}
}
/*
* '_passthrough' controls whether the source is to be 'passthrough' although there
* is a source flavor that contains transcoder settings.
* Looks for a '_passthrough' flag on the source's flavor params output.
*/
if (!isset($sourceFlavorOutput) || $sourceFlavorOutput->_passthrough == true) {
return true;
}
// save flavor params
$sourceFlavorOutput->setPartnerId($sourceFlavorOutput->getPartnerId());
$sourceFlavorOutput->setEntryId($entryId);
$sourceFlavorOutput->setFlavorAssetId($originalFlavorAsset->getId());
$sourceFlavorOutput->setFlavorAssetVersion($originalFlavorAsset->getVersion());
$sourceFlavorOutput->save();
if ($errDescription) {
$originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
}
$errDescription = kBusinessConvertDL::parseFlavorDescription($sourceFlavorOutput);
if ($errDescription) {
$originalFlavorAsset->setDescription($originalFlavorAsset->getDescription() . "\n{$errDescription}");
}
// decided by the business logic layer
if ($sourceFlavorOutput->_create_anyway) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] selected to be created anyway");
} else {
if (!$sourceFlavorOutput->IsValid()) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is invalid");
$originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$originalFlavorAsset->save();
$errDescription = "Source flavor could not be converted";
self::setError($errDescription, $convertProfileJob, BatchJobType::CONVERT_PROFILE, $convertProfileJob->getEntryId());
return false;
}
if ($sourceFlavorOutput->_force) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is forced");
} elseif ($sourceFlavorOutput->_isNonComply) {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is none-comply");
} else {
KalturaLog::log("Flavor [" . $sourceFlavorOutput->getFlavorParamsId() . "] is valid");
}
}
$originalFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_CONVERTING);
if (isset($sourceFlavor)) {
$tagsArr = $sourceFlavor->getTagsArray();
// No need for 'save_source' tag on the inter-src asset, remove it.
if (($key = array_search(assetParams::TAG_SAVE_SOURCE, $tagsArr)) !== false) {
unset($tagsArr[$key]);
}
$originalFlavorAsset->addTags($tagsArr);
$originalFlavorAsset->setFileExt($sourceFlavorOutput->getFileExt());
$originalFlavorAsset->save();
}
// save flavor params
$sourceFlavorOutput->setFlavorAssetVersion($originalFlavorAsset->getVersion());
//.........这里部分代码省略.........