public function fromObject($dbData) { parent::fromObject($dbData); $statusesArray = $dbData->getStatuses(); if (is_array($statusesArray)) { $this->statuses = KalturaSchedulerStatusArray::fromValuesArray($statusesArray, $this->schedulerId, $this->schedulerConfiguredId, $this->id, $this->configuredId, $this->type); } $this->configs = KalturaSchedulerConfigArray::fromSchedulerConfigArray($dbData->getConfigs()); $this->lockedJobs = KalturaBatchJobArray::fromBatchJobArray($dbData->getLockedJobs()); return $this; }
public function doFromObject($dbData, KalturaDetachedResponseProfile $responseProfile = null) { parent::doFromObject($dbData, $responseProfile); $statusesArray = $dbData->getStatuses(); if (is_array($statusesArray)) { $this->statuses = KalturaSchedulerStatusArray::fromValuesArray($statusesArray, $this->schedulerId, $this->schedulerConfiguredId, $this->id, $this->configuredId, $this->type); } $this->configs = KalturaSchedulerConfigArray::fromDbArray($dbData->getConfigs()); $this->lockedJobs = KalturaBatchJobArray::fromBatchJobArray($dbData->getLockedJobs()); return $this; }
/** * batch getExclusiveFileSyncImportJob action allows to get a BatchJob of type FILESYNC_IMPORT * * @action getExclusiveFileSyncImportJobs * @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 * @param int $maxOffset The maximum offset we accept for the distance from the best result. * @return KalturaBatchJobArray * * TODO remove the destFilePath from the job data and get it later using the api, then delete this method */ function getExclusiveFileSyncImportJobsAction(KalturaExclusiveLockKey $lockKey, $maxExecutionTime, $numberOfJobs, KalturaBatchJobFilter $filter = null, $maxOffset = null) { $coreJobs = $this->getExclusiveJobs($lockKey, $maxExecutionTime, $numberOfJobs, $filter, BatchJobType::FILESYNC_IMPORT, $maxOffset); $jobs = KalturaBatchJobArray::fromBatchJobArray($coreJobs); if ($jobs) { foreach ($jobs as $index => $job) { $data = $job->data; // try to get destination path from file sync $fileSyncId = $data->filesyncId; $fileSync = FileSyncPeer::retrieveByPK($fileSyncId); if (!$fileSync) { KalturaLog::err("Failed to load file sync [{$fileSyncId}] aborting job [{$job->id}]"); $dbJob = BatchJobPeer::retrieveByPK($job->id); $dbJob->setMessage("Failed to load file sync [{$fileSyncId}]"); kJobsManager::abortDbBatchJob($dbJob); unset($jobs[$index]); continue; } $fileSyncRoot = $fileSync->getFileRoot(); $fileSyncPath = $fileSync->getFilePath(); if ($fileSyncRoot && $fileSyncPath) { // destination path set on filesync $dest_path = $fileSyncRoot . $fileSyncPath; } else { // not set on filesync - get path from path manager $fileSyncKey = kFileSyncUtils::getKeyForFileSync($fileSync); list($file_root, $real_path) = kPathManager::getFilePathArr($fileSyncKey); $dest_path = $file_root . $real_path; // update filesync on database $fileSync->setFileRoot($file_root); $fileSync->setFilePath($real_path); $fileSync->save(); } // update job data with destination path if needed if (!$data->destFilePath) { $data->destFilePath = $dest_path; $job->data = $data; KalturaLog::log('Updating destination path for job id [$job->id]'); $this->updateJob($job); } if (!is_dir(dirname($dest_path)) && !@mkdir(dirname($dest_path), 0755, true)) { KalturaLog::ERR("Cannot create directory [{$dest_path}] - " . error_get_last()); } } } return $jobs; }
/** * batch getExclusiveTransformMetadataJob action allows to get a BatchJob of type METADATA_TRANSFORM * * @action getExclusiveTransformMetadataJobs * @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 * * TODO remove the destXsdPath from the job data and get it later using the api, then delete this method */ function getExclusiveTransformMetadataJobsAction(KalturaExclusiveLockKey $lockKey, $maxExecutionTime, $numberOfJobs, KalturaBatchJobFilter $filter = null) { $jobs = $this->getExclusiveJobs($lockKey, $maxExecutionTime, $numberOfJobs, $filter, BatchJobType::METADATA_TRANSFORM); if ($jobs) { foreach ($jobs as &$job) { $data = $job->getData(); $metadataProfileId = $data->getMetadataProfileId(); $metadataProfile = MetadataProfilePeer::retrieveByPK($metadataProfileId); if (!$metadataProfile) { continue; } $key = $metadataProfile->getSyncKey(MetadataProfile::FILE_SYNC_METADATA_DEFINITION); $xsdPath = kFileSyncUtils::getLocalFilePathForKey($key); $data->setDestXsdPath($xsdPath); $job->setData($data); } } return KalturaBatchJobArray::fromBatchJobArray($jobs); }
/** * batch getExclusiveAlmostDone action allows to get a BatchJob that wait for remote closure * * @action getExclusiveAlmostDone * @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 * @param KalturaBatchJobType $jobType The type of the job - could be a custom extended type * @return KalturaBatchJobArray */ function getExclusiveAlmostDoneAction(KalturaExclusiveLockKey $lockKey, $maxExecutionTime, $numberOfJobs, KalturaBatchJobFilter $filter = null, $jobType = null) { $jobType = kPluginableEnumsManager::apiToCore('BatchJobType', $jobType); $jobsFilter = new BatchJobFilter(); if ($filter) { $jobsFilter = $filter->toFilter($jobType); } $jobs = kBatchManager::getExclusiveAlmostDoneJobs($lockKey->toObject(), $maxExecutionTime, $numberOfJobs, $jobType, $jobsFilter); return KalturaBatchJobArray::fromBatchJobArray($jobs); }
/** * list Batch Jobs * * @action listBatchJobs * @param KalturaBatchJobFilter $filter * @param KalturaFilterPager $pager * @return KalturaBatchJobListResponse */ function listBatchJobsAction(KalturaBatchJobFilter $filter = null, KalturaFilterPager $pager = null) { if (!$filter) { $filter = new KalturaBatchJobFilter(); } $batchJobFilter = new BatchJobFilter(); $filter->toObject($batchJobFilter); $c = new Criteria(); // $c->add(BatchJobPeer::DELETED_AT, null); $batchJobFilter->attachToCriteria($c); if (!$pager) { $pager = new KalturaFilterPager(); } $pager->attachToCriteria($c); myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; $list = BatchJobPeer::doSelect($c); $c->setLimit(false); $count = BatchJobPeer::doCount($c); $newList = KalturaBatchJobArray::fromStatisticsBatchJobArray($list); $response = new KalturaBatchJobListResponse(); $response->objects = $newList; $response->totalCount = $count; return $response; }
/** * @param SchedulerWorker $dbData * @return KalturaScheduler */ public function statusFromObject($dbData) { $this->fromObject($dbData); $this->lockedJobs = KalturaBatchJobArray::fromBatchJobArray($dbData->getLockedJobs()); $this->avgWait = BatchJobPeer::doAvgTimeDiff($this->type, BatchJobPeer::CREATED_AT, BatchJobPeer::QUEUE_TIME, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2)); $this->avgWork = BatchJobPeer::doAvgTimeDiff($this->type, BatchJobPeer::QUEUE_TIME, BatchJobPeer::FINISH_TIME, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2)); return $this; }