/**
  * @param BatchJob $dbBatchJob
  * @param kDistributionDeleteJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob
  */
 public static function onDistributionDeleteJobFailed(BatchJob $dbBatchJob, kDistributionDeleteJobData $data, BatchJob $twinJob = null)
 {
     $entryDistribution = EntryDistributionPeer::retrieveByPK($data->getEntryDistributionId());
     if (!$entryDistribution) {
         KalturaLog::err("Entry distribution [" . $data->getEntryDistributionId() . "] not found");
         return $dbBatchJob;
     }
     $entryDistribution->setErrorType($dbBatchJob->getErrType());
     $entryDistribution->setErrorNumber($dbBatchJob->getErrNumber());
     $entryDistribution->setErrorDescription($dbBatchJob->getMessage());
     $entryDistribution->setStatus(EntryDistributionStatus::ERROR_DELETING);
     $entryDistribution->setDirtyStatus(null);
     $entryDistribution->save();
     return $dbBatchJob;
 }
Exemplo n.º 2
0
 public static function handleConvertFailed(BatchJob $dbBatchJob, $engineType, $flavorAssetId, $flavorParamsOutputId, $mediaInfoId)
 {
     $flavorAsset = assetPeer::retrieveById($flavorAssetId);
     // verifies that flavor asset exists
     if (!$flavorAsset) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $flavorAssetId);
     }
     /*
      * On Webex error, roll back the inter-src asset version in order to allow the retry to get ARF as a source, 
      * rather than the invlaid WMV file (product of bad nbrplayer session)
      */
     if ($dbBatchJob->getErrNumber() == BatchJobAppErrors::BLACK_OR_SILENT_CONTENT) {
         $prevVer = $flavorAsset->getPreviousVersion();
         $currVer = $flavorAsset->getVersion();
         KalturaLog::log("Webex conversion - Garbled Audio or Black frame or Silence. Rolling back asset/file-sync version - curr({$currVer}), prev({$prevVer})");
         if (isset($prevVer)) {
             $syncKey = $flavorAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET, $currVer);
             if (isset($syncKey)) {
                 kFileSyncUtils::deleteSyncFileForKey($syncKey, false, true);
                 $flavorAsset->setVersion($prevVer);
                 $flavorAsset->setPreviousVersion(null);
                 KalturaLog::log("Webex conversion - Rolled back");
             }
         }
     }
     $flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
     $flavorAsset->save();
     // try to create a convert job with the next engine
     if (!is_null($engineType)) {
         $data = $dbBatchJob->getData();
         if ($data instanceof kConvartableJobData) {
             $data->incrementOperationSet();
             $dbBatchJob->setData($data);
             $dbBatchJob->save();
         }
         $newDbBatchJob = kBusinessPreConvertDL::redecideFlavorConvert($flavorAssetId, $flavorParamsOutputId, $mediaInfoId, $dbBatchJob, $engineType);
         if ($newDbBatchJob) {
             return true;
         }
     }
     // find the root job
     $rootBatchJob = $dbBatchJob->getRootJob();
     if (!$rootBatchJob) {
         return false;
     }
     // the root is already failed
     if ($rootBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FAILED || $rootBatchJob->getStatus() == BatchJob::BATCHJOB_STATUS_FATAL) {
         return false;
     }
     // bulk download root job no need to handle
     if ($rootBatchJob->getJobType() == BatchJobType::BULKDOWNLOAD) {
         kJobsManager::failBatchJob($rootBatchJob, "Convert job " . $dbBatchJob->getId() . " failed");
         return false;
     }
     if (is_null($flavorParamsOutputId)) {
         kJobsManager::failBatchJob($rootBatchJob, "Job " . $dbBatchJob->getId() . " failed");
         kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
         return false;
     }
     $readyBehavior = $dbBatchJob->getData()->getReadyBehavior();
     if ($readyBehavior == flavorParamsConversionProfile::READY_BEHAVIOR_REQUIRED) {
         kJobsManager::failBatchJob($rootBatchJob, "Job " . $dbBatchJob->getId() . " failed");
         kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
         return false;
     }
     // failing the root profile job if all child jobs failed
     if ($rootBatchJob->getJobType() != BatchJobType::CONVERT_PROFILE) {
         return false;
     }
     $siblingJobs = $rootBatchJob->getChildJobs();
     foreach ($siblingJobs as $siblingJob) {
         /* @var $siblingJob BatchJob */
         // not conversion job and should be ignored
         if ($siblingJob->getJobType() != BatchJobType::CONVERT && $siblingJob->getJobType() != BatchJobType::POSTCONVERT) {
             continue;
         }
         $jobData = $siblingJob->getData();
         if (!$jobData || !$jobData instanceof kConvertJobData && !$jobData instanceof kPostConvertJobData) {
             KalturaLog::err("Job id [" . $siblingJob->getId() . "] has no valid job data");
             continue;
         }
         // found child flavor asset that hasn't failed, no need to fail the root job
         $siblingFlavorAssetId = $jobData->getFlavorAssetId();
         $siblingFlavorAsset = assetPeer::retrieveById($siblingFlavorAssetId);
         if ($siblingFlavorAsset && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_ERROR && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_NOT_APPLICABLE && $siblingFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_DELETED) {
             return false;
         }
     }
     // all conversions failed, should fail the root job
     kJobsManager::failBatchJob($rootBatchJob, "All conversions failed");
     kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
     return false;
 }
Exemplo n.º 3
0
 public static function preBatchJobUpdate(BatchJob $batchJob)
 {
     if ($batchJob->isColumnModified(BatchJobPeer::ERR_NUMBER) || $batchJob->isColumnModified(BatchJobPeer::ERR_TYPE) || $batchJob->isColumnModified(BatchJobPeer::MESSAGE)) {
         $historyRecord = new kBatchHistoryData();
         $historyRecord->setErrNumber($batchJob->getErrNumber());
         $historyRecord->setErrType($batchJob->getErrType());
         $historyRecord->setMessage($batchJob->getMessage());
         $batchJob->addHistoryRecord($historyRecord);
     }
 }
Exemplo n.º 4
0
 public static function handleLiveReportExportFailed(BatchJob $dbBatchJob, kLiveReportExportJobData $data)
 {
     $time = date("m-d-y H:i", $data->timeReference + $data->timeZoneOffset);
     $email_id = MailType::MAIL_TYPE_LIVE_REPORT_EXPORT_FAILURE;
     $params = array($dbBatchJob->getPartner()->getName(), $time, $dbBatchJob->getId(), $dbBatchJob->getErrType(), $dbBatchJob->getErrNumber());
     $titleParams = array($time);
     kJobsManager::addMailJob(null, 0, $dbBatchJob->getPartnerId(), $email_id, kMailJobData::MAIL_PRIORITY_NORMAL, kConf::get("live_report_sender_email"), kConf::get("live_report_sender_name"), $data->recipientEmail, $params, $titleParams);
     return $dbBatchJob;
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kStorageExportJobData $data
  * @return BatchJob
  */
 public static function handleStorageExportFailed(BatchJob $dbBatchJob, kStorageExportJobData $data)
 {
     KalturaLog::debug("Export to storage failed for sync file[" . $data->getSrcFileSyncId() . "]");
     if ($dbBatchJob->getErrType() == BatchJobErrorTypes::APP && $dbBatchJob->getErrNumber() == BatchJobAppErrors::FILE_ALREADY_EXISTS) {
         KalturaLog::notice("remote file already exists");
         return $dbBatchJob;
     }
     $fileSync = FileSyncPeer::retrieveByPK($data->getSrcFileSyncId());
     $fileSync->setStatus(FileSync::FILE_SYNC_STATUS_ERROR);
     $fileSync->save();
     // if an asset was exported - check if should set its status to ERROR
     $asset = assetPeer::retrieveByFileSync($fileSync);
     if ($asset && $asset->getStatus() == asset::ASSET_STATUS_EXPORTING) {
         $asset->setStatus(asset::ASSET_STATUS_ERROR);
         $asset->save();
         if ($asset instanceof flavorAsset) {
             $flavorParamsOutput = $asset->getFlavorParamsOutput();
             $flavorParamsOutputId = $flavorParamsOutput ? $flavorParamsOutput->getId() : null;
             $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($asset->getId());
             $mediaInfoId = $mediaInfo ? $mediaInfo->getId() : null;
             kBusinessPostConvertDL::handleConvertFailed($dbBatchJob, null, $asset->getId(), $flavorParamsOutputId, $mediaInfoId);
         }
     }
     return $dbBatchJob;
 }