本文整理汇总了PHP中BatchJob::getBulkJobId方法的典型用法代码示例。如果您正苦于以下问题:PHP BatchJob::getBulkJobId方法的具体用法?PHP BatchJob::getBulkJobId怎么用?PHP BatchJob::getBulkJobId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BatchJob
的用法示例。
在下文中一共展示了BatchJob::getBulkJobId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addJob
/**
* @param BatchJob $batchJob
* @param $data
* @param int $type
* @param int $subType
* @return BatchJob
*/
public static function addJob(BatchJob $batchJob, $data, $type, $subType = null)
{
$batchJob->setJobType($type);
$batchJob->setJobSubType($subType);
$batchJob->setData($data);
if (!$batchJob->getParentJobId() && $batchJob->getEntryId()) {
$currentJob = kBatchManager::getCurrentUpdatingJob();
if ($currentJob && $currentJob->getEntryId() == $batchJob->getEntryId()) {
$batchJob->setParentJobId($currentJob->getId());
$batchJob->setBulkJobId($currentJob->getBulkJobId());
$batchJob->setRootJobId($currentJob->getRootJobId());
} else {
$entry = entryPeer::retrieveByPKNoFilter($batchJob->getEntryId());
// some jobs could be on deleted entry
if ($entry) {
$batchJob->setRootJobId($entry->getBulkUploadId());
$batchJob->setBulkJobId($entry->getBulkUploadId());
}
}
}
// validate partner id
$partnerId = $batchJob->getPartnerId();
// if(!$partnerId)
// throw new APIException(APIErrors::PARTNER_NOT_SET);
// validate that partner exists
$partner = PartnerPeer::retrieveByPK($partnerId);
if (!$partner) {
KalturaLog::err("Invalid partner id [{$partnerId}]");
throw new APIException(APIErrors::INVALID_PARTNER_ID, $partnerId);
}
// set the priority and work group
$batchJob->setPriority($partner->getPriority($batchJob->getBulkJobId()));
$batchJob = self::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING);
// look for identical jobs
$twinJobs = BatchJobPeer::retrieveDuplicated($type, $data);
$twinJob = null;
if (count($twinJobs)) {
foreach ($twinJobs as $currentTwinJob) {
if ($currentTwinJob->getId() != $batchJob->getId()) {
$twinJob = reset($twinJobs);
}
}
}
if (!is_null($twinJob)) {
$batchJob->setTwinJobId($twinJob->getId());
if (!kConf::get("batch_ignore_duplication")) {
$batchJob = self::updateBatchJob($batchJob, $twinJob->getStatus(), $twinJob);
} else {
$batchJob->save();
}
}
return $batchJob;
}
示例2: calculateUrgency
function calculateUrgency(BatchJob $batchJob)
{
$flavorParamsId = $this->getFlavorParamsOutput()->getFlavorParamsId();
$isBulkupload = $batchJob->getBulkJobId() !== null;
$readiness = null;
if ($this->priority == 0) {
self::calculatePriority($batchJob);
}
if ($this->priority == self::MIGRATION_FLAVOR_PRIORITY) {
return BatchJobUrgencyType::MIGRATION_URGENCY;
}
// If you have no conversion profile, there is no poinr in this calculation
if (is_null($this->conversionProfileId)) {
return BatchJobUrgencyType::DEFAULT_URGENCY;
}
if ($batchJob->getObjectId() && $batchJob->getObjectType()) {
$batchJobs = BatchJobPeer::retrieveByJobTypeAndObject($batchJob->getObjectId(), $batchJob->getObjectType(), $batchJob->getJobType(), $batchJob->getJobSubType());
if (count($batchJobs)) {
return $batchJobs[0]->getLockInfo()->getUrgency() + 1;
}
}
// a conversion job will be considered as required in one of the following cases:
// 1. The flavor is required
// 2. There are no required flavors and this is the flavor is optional with the minimal bitrate
// 3. all flavors are set as READY_BEHAVIOR_NO_IMPACT.
$allFlavorParamsIds = array();
$hasRequired = false;
$allNoImpact = true;
// Go over all flavors and decide on cases 1-3
$fpcps = flavorParamsConversionProfilePeer::retrieveByConversionProfile($this->conversionProfileId);
foreach ($fpcps as $fpcp) {
$allFlavorParamsIds[] = $fpcp->getFlavorParamsId();
if ($fpcp->getFlavorParamsId() == $flavorParamsId) {
// Case 1
$readiness = $fpcp->getReadyBehavior();
}
if ($fpcp->getReadyBehavior() == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) {
// Case 2
$hasRequired = true;
}
if ($fpcp->getReadyBehavior() != flavorParamsConversionProfile::READY_BEHAVIOR_NO_IMPACT) {
// Case 3
$allNoImpact = false;
}
}
// Case 2
if (!$hasRequired && $readiness == flavorParamsConversionProfile::READY_BEHAVIOR_OPTIONAL) {
$flvParamsMinBitrate = assetParamsPeer::retrieveMinimalBitrate($allFlavorParamsIds);
if (!is_null($flvParamsMinBitrate) && $flvParamsMinBitrate->getId() == $flavorParamsId) {
$readiness = flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED;
}
}
// Case 3
if ($allNoImpact) {
$readiness = flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED;
}
// Decide on the urgency by the readiness and the upload method
if ($readiness == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) {
return $isBulkupload ? BatchJobUrgencyType::REQUIRED_BULK_UPLOAD : BatchJobUrgencyType::REQUIRED_REGULAR_UPLOAD;
} else {
if ($readiness == flavorParamsConversionProfile::READY_BEHAVIOR_OPTIONAL) {
return $isBulkupload ? BatchJobUrgencyType::OPTIONAL_BULK_UPLOAD : BatchJobUrgencyType::OPTIONAL_REGULAR_UPLOAD;
} else {
return BatchJobUrgencyType::DEFAULT_URGENCY;
}
}
}
示例3: calculateUrgency
/**
* This function calculates the urgency of the job according to its data
* @param BatchJob $batchJob
* @return integer the calculated urgency
*/
public function calculateUrgency(BatchJob $batchJob)
{
return $batchJob->getBulkJobId() === NULL ? BatchJobUrgencyType::REQUIRED_REGULAR_UPLOAD : BatchJobUrgencyType::REQUIRED_BULK_UPLOAD;
}