本文整理汇总了PHP中BatchJob::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP BatchJob::getId方法的具体用法?PHP BatchJob::getId怎么用?PHP BatchJob::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BatchJob
的用法示例。
在下文中一共展示了BatchJob::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doConsume
/**
* @param kBatchJobStatusEventConsumer $consumer
* @return bool true if should continue to the next consumer
*/
protected function doConsume(KalturaEventConsumer $consumer)
{
if (!$consumer->shouldConsumeJobStatusEvent($this->dbBatchJob)) {
return true;
}
KalturaLog::debug(get_class($this) . " event consumed by " . get_class($consumer) . " job id [" . $this->dbBatchJob->getId() . "] type [" . $this->dbBatchJob->getJobType() . "] sub type [" . $this->dbBatchJob->getJobSubType() . "] status [" . $this->dbBatchJob->getStatus() . "]");
return $consumer->updatedJob($this->dbBatchJob, $this->twinJob);
}
示例2: doConsume
protected function doConsume(KalturaEventConsumer $consumer)
{
if (!$consumer->shouldConsumeIntegrationCloseEvent($this->object, $this->modifiedColumns)) {
return true;
}
KalturaLog::debug('consumer [' . get_class($consumer) . '] started handling [' . get_class($this) . '] batch-job id [' . $this->batchJob->getId() . '] status [' . $this->batchJob->getStatus() . ']');
$result = $consumer->integrationJobClosed($this->batchJob);
KalturaLog::debug('consumer [' . get_class($consumer) . '] finished handling [' . get_class($this) . '] batch-job id [' . $this->batchJob->getId() . '] status [' . $this->batchJob->getStatus() . ']');
return $result;
}
示例3: doConsume
/**
* @param kBatchJobStatusEventConsumer $consumer
* @return bool true if should continue to the next consumer
*/
protected function doConsume(KalturaEventConsumer $consumer)
{
if (!$consumer->shouldConsumeJobStatusEvent($this->dbBatchJob)) {
return true;
}
KalturaLog::debug('consumer [' . get_class($consumer) . '] started handling [' . get_class($this) . '] job id [' . $this->dbBatchJob->getId() . '] type [' . $this->dbBatchJob->getJobType() . '] sub type [' . $this->dbBatchJob->getJobSubType() . '] status [' . $this->dbBatchJob->getStatus() . ']');
$result = $consumer->updatedJob($this->dbBatchJob);
KalturaLog::debug('consumer [' . get_class($consumer) . '] finished handling [' . get_class($this) . '] job id [' . $this->dbBatchJob->getId() . '] type [' . $this->dbBatchJob->getJobType() . '] sub type [' . $this->dbBatchJob->getJobSubType() . '] status [' . $this->dbBatchJob->getStatus() . ']');
return $result;
}
示例4: abortChildJobs
/**
* @param BatchJob $dbBatchJob
*/
public static function abortChildJobs(BatchJob $dbBatchJob)
{
// aborts all child jobs
$dbChildJobs = $dbBatchJob->getChildJobs();
foreach ($dbChildJobs as $dbChildJob) {
if ($dbChildJob->getId() != $dbBatchJob->getId()) {
self::abortDbBatchJob($dbChildJob);
}
}
}
示例5: __construct
/**
* @param BaseObject $object
* @param BatchJob $raisedJob
*/
public function __construct(BaseObject $object, BatchJob $raisedJob = null)
{
$this->object = $object;
$this->raisedJob = $raisedJob;
$additionalLog = '';
if (method_exists($object, 'getId')) {
$additionalLog .= ' id [' . $object->getId() . ']';
}
if ($raisedJob) {
$additionalLog .= ' raised job id [' . $raisedJob->getId() . '] of type [' . $raisedJob->getJobType() . ']';
}
KalturaLog::debug("Event [" . get_class($this) . "] object type [" . get_class($object) . "]" . $additionalLog);
}
示例6: addConvertProfileJob
/**
* @param BatchJob $batchJob
* @param entry $entry
* @param string $flavorAssetId
* @param string $inputFileSyncLocalPath
* @return BatchJob
*/
public static function addConvertProfileJob(BatchJob $parentJob = null, entry $entry, $flavorAssetId, $inputFileSyncLocalPath)
{
KalturaLog::debug("Parent job [" . ($parentJob ? $parentJob->getId() : 'none') . "] entry [" . $entry->getId() . "] flavor asset [{$flavorAssetId}] input file [{$inputFileSyncLocalPath}]");
if ($entry->getConversionQuality() == conversionProfile2::CONVERSION_PROFILE_NONE) {
$entry->setStatus(entryStatus::PENDING);
$entry->save();
KalturaLog::notice('Entry should not be converted');
return null;
}
$importingSources = false;
// if file size is 0, do not create conversion profile and set entry status as error converting
if (!file_exists($inputFileSyncLocalPath) || kFile::fileSize($inputFileSyncLocalPath) == 0) {
KalturaLog::debug("Input file [{$inputFileSyncLocalPath}] does not exist");
$partner = $entry->getPartner();
$conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entry->getId());
// load the asset params to the instance pool
$flavorIds = flavorParamsConversionProfilePeer::getFlavorIdsByProfileId($conversionProfile->getId());
assetParamsPeer::retrieveByPKs($flavorIds);
$conversionRequired = false;
$sourceFileRequiredStorages = array();
$sourceIncludedInProfile = false;
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
$flavors = flavorParamsConversionProfilePeer::retrieveByConversionProfile($conversionProfile->getId());
KalturaLog::debug("Found flavors [" . count($flavors) . "] in conversion profile [" . $conversionProfile->getId() . "]");
foreach ($flavors as $flavor) {
/* @var $flavor flavorParamsConversionProfile */
if ($flavor->getFlavorParamsId() == $flavorAsset->getFlavorParamsId()) {
KalturaLog::debug("Flavor [" . $flavor->getFlavorParamsId() . "] is ingested source");
$sourceIncludedInProfile = true;
continue;
}
$flavorParams = assetParamsPeer::retrieveByPK($flavor->getFlavorParamsId());
if ($flavorParams instanceof liveParams || $flavor->getOrigin() == assetParamsOrigin::INGEST) {
KalturaLog::debug("Flavor [" . $flavor->getFlavorParamsId() . "] should be ingested");
continue;
}
if ($flavor->getOrigin() == assetParamsOrigin::CONVERT_WHEN_MISSING) {
$siblingFlavorAsset = assetPeer::retrieveByEntryIdAndParams($entry->getId(), $flavor->getFlavorParamsId());
if ($siblingFlavorAsset) {
KalturaLog::debug("Flavor [" . $flavor->getFlavorParamsId() . "] already ingested");
continue;
}
}
$sourceFileRequiredStorages[] = $flavorParams->getSourceRemoteStorageProfileId();
$conversionRequired = true;
break;
}
if ($conversionRequired) {
foreach ($sourceFileRequiredStorages as $storageId) {
if ($storageId == StorageProfile::STORAGE_KALTURA_DC) {
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($syncFile, $local) = kFileSyncUtils::getReadyFileSyncForKey($key, true, false);
if ($syncFile && $syncFile->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL && $partner && $partner->getImportRemoteSourceForConvert()) {
KalturaLog::debug("Creates import job for remote file sync");
$url = $syncFile->getExternalUrl($entry->getId());
kJobsManager::addImportJob($parentJob, $entry->getId(), $partner->getId(), $url, $flavorAsset, null, null, true);
$importingSources = true;
continue;
}
} elseif ($flavorAsset->getExternalUrl($storageId)) {
continue;
}
kBatchManager::updateEntry($entry->getId(), entryStatus::ERROR_CONVERTING);
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$flavorAsset->setDescription('Entry of size 0 should not be converted');
$flavorAsset->save();
KalturaLog::err('Entry of size 0 should not be converted');
return null;
}
} else {
if ($flavorAsset->getStatus() == asset::FLAVOR_ASSET_STATUS_QUEUED) {
if ($sourceIncludedInProfile) {
$flavorAsset->setStatusLocalReady();
} else {
$flavorAsset->setStatus(asset::FLAVOR_ASSET_STATUS_DELETED);
$flavorAsset->setDeletedAt(time());
}
$flavorAsset->save();
if ($sourceIncludedInProfile) {
kBusinessPostConvertDL::handleConvertFinished(null, $flavorAsset);
}
}
return null;
}
}
if ($entry->getStatus() != entryStatus::READY) {
$entry->setStatus(entryStatus::PRECONVERT);
}
$jobData = new kConvertProfileJobData();
$jobData->setFlavorAssetId($flavorAssetId);
$jobData->setInputFileSyncLocalPath($inputFileSyncLocalPath);
$jobData->setExtractMedia(true);
//.........这里部分代码省略.........
示例7: handleConvertCollectionFailed
/**
* @param BatchJob $dbBatchJob
* @param kConvertCollectionJobData $data
* @param int $engineType
* @return boolean
*/
public static function handleConvertCollectionFailed(BatchJob $dbBatchJob, kConvertCollectionJobData $data, $engineType)
{
$collectionFlavors = array();
foreach ($data->getFlavors() as $flavor) {
$collectionFlavors[$flavor->getFlavorAssetId()] = $flavor;
}
// find the root job
$rootBatchJob = $dbBatchJob->getRootJob();
$hasIncomplete = false;
$shouldFailProfile = false;
$flavorAssets = assetPeer::retrieveFlavorsByEntryId($dbBatchJob->getEntryId());
foreach ($flavorAssets as $flavorAsset) {
if (isset($collectionFlavors[$flavorAsset->getId()])) {
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$flavorAsset->save();
if (!$rootBatchJob) {
continue;
}
$flavorData = $collectionFlavors[$flavorAsset->getId()];
if ($flavorData->getReadyBehavior() == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) {
$shouldFailProfile = true;
}
continue;
}
if ($flavorAsset->getIsOriginal()) {
continue;
}
if ($flavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_QUEUED || $flavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_CONVERTING || $flavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_IMPORTING || $flavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_VALIDATING) {
$hasIncomplete = true;
}
}
if (!$rootBatchJob) {
return false;
}
if ($rootBatchJob->getJobType() != BatchJobType::CONVERT_PROFILE) {
return false;
}
if ($shouldFailProfile || !$hasIncomplete) {
kJobsManager::failBatchJob($rootBatchJob, "Job " . $dbBatchJob->getId() . " failed");
}
return false;
}
示例8: batchJobDeleted
/**
* @param BatchJob $batchJob
*/
protected function batchJobDeleted(BatchJob $batchJob)
{
$this->syncableDeleted($batchJob->getId(), FileSyncObjectType::BATCHJOB);
}
示例9: abortChildJobs
/**
* @param BatchJob $dbBatchJob
*/
public static function abortChildJobs(BatchJob $dbBatchJob)
{
$maxJobsForQuery = 100;
$c = new Criteria();
$c->add(BatchJobPeer::STATUS, BatchJobPeer::getClosedStatusList(), Criteria::NOT_IN);
$c->setLimit($maxJobsForQuery);
// aborts all child jobs in chunks
while (true) {
$dbChildJobs = $dbBatchJob->getChildJobs($c);
foreach ($dbChildJobs as $dbChildJob) {
$dbChildJob->setMessage("Parent job was aborted.");
if ($dbChildJob->getId() != $dbBatchJob->getId()) {
self::abortDbBatchJob($dbChildJob);
}
}
if (count($dbChildJobs) < $maxJobsForQuery) {
break;
}
}
}
示例10: getBulkUploadMrssXml
/**
* Returns the log file for bulk upload job
* @param BatchJob $batchJob bulk upload batchjob
* @return SimpleXMLElement
*/
public static function getBulkUploadMrssXml($batchJob)
{
$actionsMap = array(BulkUploadAction::ADD => 'add', BulkUploadAction::UPDATE => 'update', BulkUploadAction::DELETE => 'delete');
$bulkUploadResults = BulkUploadResultPeer::retrieveByBulkUploadId($batchJob->getId());
if (!count($bulkUploadResults)) {
return null;
}
header("Content-Type: text/xml; charset=UTF-8");
$data = $batchJob->getData();
$xmlElement = new SimpleXMLElement('<mrss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>');
$xmlElement->addAttribute('version', '2.0');
// $xmlElement->addAttribute('xmlns:content', 'http://www.w3.org/2001/XMLSchema-instance');
// $xmlElement->addAttribute('xmlns', 'http://' . kConf::get('www_host') . '/' . SchemaType::SYNDICATION);
// $xmlElement->addAttribute('xsi:noNamespaceSchemaLocation', 'http://' . kConf::get('cdn_host') . '/api_v3/service/schema/action/serve/type/' . SchemaType::SYNDICATION);
$channel = $xmlElement->addChild('channel');
// insert all entries to instance pool
$pks = array();
foreach ($bulkUploadResults as $bulkUploadResult) {
/* @var $bulkUploadResult BulkUploadResult */
$pks[] = $bulkUploadResult->getEntryId();
}
entryPeer::retrieveByPKs($pks);
foreach ($bulkUploadResults as $bulkUploadResult) {
/* @var $bulkUploadResult BulkUploadResult */
$item = $channel->addChild('item');
$result = $item->addChild('result');
$result->addChild('errorDescription', self::stringToSafeXml($bulkUploadResult->getErrorDescription()));
// $result->addChild('entryStatus', self::stringToSafeXml($bulkUploadResult->getEntryStatus()));
// $result->addChild('entryStatusName', self::stringToSafeXml($title));
$action = isset($actionsMap[$bulkUploadResult->getAction()]) ? $actionsMap[$bulkUploadResult->getAction()] : $actionsMap[BulkUploadAction::ADD];
$item->addChild('action', $action);
$entry = $bulkUploadResult->getObject();
if (!$entry) {
continue;
}
kMrssManager::getEntryMrssXml($entry, $item);
}
return $xmlElement;
}
示例11: writeBulkUploadLogFile
/**
* Returns the log file for bulk upload job
* @param BatchJob $batchJob bulk upload batchjob
*/
public static function writeBulkUploadLogFile($batchJob)
{
if ($batchJob->getJobSubType() && $batchJob->getJobSubType() != self::getBulkUploadTypeCoreValue(BulkUploadCsvType::CSV)) {
return;
}
header("Content-Type: text/plain; charset=UTF-8");
$criteria = new Criteria();
$criteria->add(BulkUploadResultPeer::BULK_UPLOAD_JOB_ID, $batchJob->getId());
$criteria->addAscendingOrderByColumn(BulkUploadResultPeer::LINE_INDEX);
$criteria->setLimit(100);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
if (!count($bulkUploadResults)) {
die("Log file is not ready");
}
$STDOUT = fopen('php://output', 'w');
$data = $batchJob->getData();
/* @var $data kBulkUploadJobData */
//Add header row to the output CSV only if partner level permission for it exists
$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
if (PermissionPeer::isValidForPartner(self::FEATURE_CSV_HEADER_ROW, $partnerId)) {
$headerRow = $data->getColumns();
$headerRow[] = "resultStatus";
$headerRow[] = "objectId";
$headerRow[] = "objectStatus";
$headerRow[] = "errorDescription";
fputcsv($STDOUT, $headerRow);
}
$handledResults = 0;
while (count($bulkUploadResults)) {
$handledResults += count($bulkUploadResults);
foreach ($bulkUploadResults as $bulkUploadResult) {
/* @var $bulkUploadResult BulkUploadResult */
$values = str_getcsv($bulkUploadResult->getRowData());
// switch ($bulkUploadResult->getObjectType())
// {
// case BulkUploadObjectType::ENTRY:
// $values = self::writeEntryBulkUploadResults($bulkUploadResult, $data);
// break;
// case BulkUploadObjectType::CATEGORY:
// $values = self::writeCategoryBulkUploadResults($bulkUploadResult, $data);
// break;
// case BulkUploadObjectType::CATEGORY_USER:
// $values = self::writeCategoryUserBulkUploadResults($bulkUploadResult, $data);
// break;
// case BulkUploadObjectType::USER:
// $values = self::writeUserBulkUploadResults($bulkUploadResult, $data);
// break;
// default:
//
// break;
// }
$values[] = $bulkUploadResult->getStatus();
$values[] = $bulkUploadResult->getObjectId();
$values[] = $bulkUploadResult->getObjectStatus();
$values[] = preg_replace('/[\\n\\r\\t]/', ' ', $bulkUploadResult->getErrorDescription());
fputcsv($STDOUT, $values);
}
if (count($bulkUploadResults) < $criteria->getLimit()) {
break;
}
kMemoryManager::clearMemory();
$criteria->setOffset($handledResults);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
}
fclose($STDOUT);
kFile::closeDbConnections();
exit;
}
示例12: updateLockObject
public static function updateLockObject(BatchJob $batchJob, PropelPDO $con = null)
{
$batchJobLock = $batchJob->getBatchJobLock();
if ($batchJobLock === null) {
KalturaLog::info("Lock object wasn't found for Batch Job " . $batchJob->getId());
return;
}
self::commonLockObjectUpdate($batchJob, $batchJobLock);
// Don't add save batch job lock, it's done automatically by the save of the batch job!
$result = array_intersect(self::$LOCK_AFFECTED_BY_COLUMNS_NAMES, $batchJob->getModifiedColumns());
if (count($result) > 0) {
$version = $batchJobLock->getVersion() + 1;
// update
$batchJobLock->setVersion($version);
// update lock info
$lockInfo = $batchJob->getLockInfo();
$lockInfo->setLockVersion($version);
$batchJob->setLockInfo($lockInfo);
}
}
示例13: addInstanceToPool
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doSelect*()
* methods in your stub classes -- you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by doSelect*()
* and retrieveByPK*() calls.
*
* @param BatchJob $value A BatchJob object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(BatchJob $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getId();
}
if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
self::$instances[$key] = $obj;
kMemoryManager::registerPeer('BatchJobPeer');
}
}
}
示例14: getBulkUploadMrssXml
/**
* Returns the log file for bulk upload job
* @param BatchJob $batchJob bulk upload batchjob
* @return SimpleXMLElement
*/
public static function getBulkUploadMrssXml($batchJob)
{
$actionsMap = array(BulkUploadAction::ADD => 'add', BulkUploadAction::UPDATE => 'update', BulkUploadAction::DELETE => 'delete');
$criteria = new Criteria();
$criteria->add(BulkUploadResultPeer::BULK_UPLOAD_JOB_ID, $batchJob->getId());
$criteria->addAscendingOrderByColumn(BulkUploadResultPeer::LINE_INDEX);
$criteria->setLimit(100);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
if (!count($bulkUploadResults)) {
return null;
}
header("Content-Type: text/xml; charset=UTF-8");
$data = $batchJob->getData();
$xmlElement = new SimpleXMLElement('<mrss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>');
$xmlElement->addAttribute('version', '2.0');
$channel = $xmlElement->addChild('channel');
$handledResults = 0;
while (count($bulkUploadResults)) {
$handledResults += count($bulkUploadResults);
// insert all entries to instance pool
$pks = array();
foreach ($bulkUploadResults as $bulkUploadResult) {
/* @var $bulkUploadResult BulkUploadResult */
$pks[] = $bulkUploadResult->getEntryId();
}
entryPeer::retrieveByPKs($pks);
foreach ($bulkUploadResults as $bulkUploadResult) {
/* @var $bulkUploadResult BulkUploadResult */
$item = $channel->addChild('item');
$result = $item->addChild('result');
$result->addChild('errorDescription', self::stringToSafeXml($bulkUploadResult->getErrorDescription()));
// $result->addChild('entryStatus', self::stringToSafeXml($bulkUploadResult->getEntryStatus()));
// $result->addChild('entryStatusName', self::stringToSafeXml($title));
$action = isset($actionsMap[$bulkUploadResult->getAction()]) ? $actionsMap[$bulkUploadResult->getAction()] : $actionsMap[BulkUploadAction::ADD];
$item->addChild('action', $action);
$entry = $bulkUploadResult->getObject();
if (!$entry) {
continue;
}
kMrssManager::getEntryMrssXml($entry, $item);
}
if (count($bulkUploadResults) < $criteria->getLimit()) {
break;
}
kMemoryManager::clearMemory();
$criteria->setOffset($handledResults);
$bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
}
return $xmlElement;
}
示例15: handlePullFailed
/**
* @param BatchJob $dbBatchJob
* @param kPullJobData $data
* @param BatchJob $twinJob
* @return BatchJob
*/
public static function handlePullFailed(BatchJob $dbBatchJob, kPullJobData $data, BatchJob $twinJob = null)
{
$rootBatchJob = $dbBatchJob->getRootJob();
if ($rootBatchJob) {
$rootBatchJob = kJobsManager::failBatchJob($rootBatchJob, "Pull job " . $dbBatchJob->getId() . " failed");
}
return $dbBatchJob;
}