public static function failBatchJob(BatchJob $batchJob, $errDescription) { $batchJob->setMessage($errDescription); $description = $batchJob->getDescription() . "\n{$errDescription}"; $batchJob->setDescription($description); return self::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_FAILED); }
/** * @param BatchJob $job * @param $errorDescription * @return BatchJob */ protected function finishJobWithError(BatchJob $job, $errorDescription) { $job->setStatus(BatchJob::BATCHJOB_STATUS_FAILED); $job->setDescription($job->getDescription() . '\\n' . $errorDescription); $job->save(); return $job; }
public static function handleBulkDownloadPending(BatchJob $dbBatchJob, kBulkDownloadJobData $data, BatchJob $twinJob = null) { $entryIds = explode(',', $data->getEntryIds()); $flavorParamsId = $data->getFlavorParamsId(); $jobIsFinished = true; foreach ($entryIds as $entryId) { $entry = entryPeer::retrieveByPK($entryId); if (is_null($entry)) { KalturaLog::err("Entry id [{$entryId}] not found."); } else { if ($entry->hasDownloadAsset($flavorParamsId)) { // why we don't send the notification in case of image is ready? $flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entryId, $flavorParamsId); if ($flavorAsset && $flavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) { $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $downloadUrl = $flavorAsset->getDownloadUrl(); $localPath = kFileSyncUtils::getLocalFilePathForKey($syncKey); $downloadUrl = $flavorAsset->getDownloadUrl(); $notificationData = array("puserId" => $entry->getPuserId(), "entryId" => $entry->getId(), "entryIntId" => $entry->getIntId(), "entryVersion" => $entry->getVersion(), "fileFormat" => $flavorAsset->getFileExt(), "archivedFile" => $localPath, "downoladPath" => $localPath, "conversionQuality" => $entry->getConversionQuality(), "downloadUrl" => $downloadUrl); $extraData = array("data" => json_encode($notificationData), "partner_id" => $entry->getPartnerId(), "puser_id" => $entry->getPuserId(), "entry_id" => $entry->getId(), "entry_int_id" => $entry->getIntId(), "entry_version" => $entry->getVersion(), "file_format" => $flavorAsset->getFileExt(), "archived_file" => $localPath, "downolad_path" => $localPath, "target" => $localPath, "conversion_quality" => $entry->getConversionQuality(), "download_url" => $downloadUrl, "status" => $entry->getStatus(), "abort" => $dbBatchJob->getAbort(), "progress" => $dbBatchJob->getProgress(), "message" => $dbBatchJob->getMessage(), "description" => $dbBatchJob->getDescription(), "updates_count" => $dbBatchJob->getUpdatesCount(), "job_type" => BatchJobType::DOWNLOAD, "status" => BatchJob::BATCHJOB_STATUS_FINISHED, "progress" => 100, "debug" => __LINE__); myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_BATCH_JOB_SUCCEEDED, $dbBatchJob, $dbBatchJob->getPartnerId(), null, null, $extraData, $entryId); } } else { $jobIsFinished = false; $entry->createDownloadAsset($dbBatchJob, $flavorParamsId, $data->getPuserId()); } } } if ($jobIsFinished) { // mark the job as finished $dbBatchJob = kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED); } else { // mark the job as almost done $dbBatchJob = kJobsManager::updateBatchJob($dbBatchJob, BatchJob::BATCHJOB_STATUS_ALMOST_DONE); } return $dbBatchJob; }