/** * @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() . "]"); $fileSync = FileSyncPeer::retrieveByPK($data->getSrcFileSyncId()); $fileSync->setStatus(FileSync::FILE_SYNC_STATUS_ERROR); $fileSync->save(); return $dbBatchJob; }
/** * @param BatchJob $parentJob * @param string $entryId * @param int $partnerId * @param StorageProfile $externalStorage * @param SyncFile $fileSync * @param string $srcFileSyncLocalPath * @param bool $force * * @return BatchJob */ public static function addStorageExportJob(BatchJob $parentJob = null, $entryId, $partnerId, StorageProfile $externalStorage, FileSync $fileSync, $srcFileSyncLocalPath, $force = false, $dc = null) { KalturaLog::debug("entryId[{$entryId}], partnerId[{$partnerId}], externalStorage id[" . $externalStorage->getId() . "], fileSync id[" . $fileSync->getId() . "], srcFileSyncLocalPath[{$srcFileSyncLocalPath}]"); $netStorageExportData = kStorageExportJobData::getInstance($externalStorage->getProtocol()); $netStorageExportData->setStorageExportJobData($externalStorage, $fileSync, $srcFileSyncLocalPath); $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild(BatchJobType::STORAGE_EXPORT, $externalStorage->getProtocol(), false); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($entryId); $batchJob->setPartnerId($partnerId); } $batchJob->setObjectId($fileSync->getId()); $batchJob->setObjectType(BatchJobObjectType::FILE_SYNC); $batchJob->setJobSubType($externalStorage->getProtocol()); $batchJob->setDc($dc); KalturaLog::log("Creating Storage export job, with source file: " . $netStorageExportData->getSrcFileSyncLocalPath()); return self::addJob($batchJob, $netStorageExportData, BatchJobType::STORAGE_EXPORT, $externalStorage->getProtocol()); }
/** * @param BatchJob $dbBatchJob * @param kStorageExportJobData $data * @return BatchJob */ public static function handleStorageExportFailed(BatchJob $dbBatchJob, kStorageExportJobData $data) { if ($dbBatchJob->getErrType() == BatchJobErrorTypes::APP && $dbBatchJob->getErrNumber() == BatchJobAppErrors::FILE_ALREADY_EXISTS) { KalturaLog::notice("remote file already exists"); return $dbBatchJob; } $fileSync = FileSyncPeer::retrieveByPK($data->getSrcFileSyncId()); if (!$fileSync) { KalturaLog::err("FileSync [" . $data->getSrcFileSyncId() . "] not found"); return $dbBatchJob; } $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; }
public function setStorageExportJobData(StorageProfile $externalStorage, FileSync $fileSync, $srcFileSyncLocalPath, $force = false) { parent::setStorageExportJobData($externalStorage, $fileSync, $srcFileSyncLocalPath); $this->setFilesPermissionInS3($externalStorage->getFilesPermissionInS3()); $this->setS3Region($externalStorage->getS3Region()); }
/** * @param BatchJob $parentJob * @param string $entryId * @param int $partnerId * @param StorageProfile $externalStorage * @param SyncFile $fileSync * @param string $srcFileSyncLocalPath * @param bool $force * * @return BatchJob */ public static function addStorageExportJob(BatchJob $parentJob = null, $entryId, $partnerId, StorageProfile $externalStorage, FileSync $fileSync, $srcFileSyncLocalPath, $force = false, $dc = null) { KalturaLog::debug("entryId[{$entryId}], partnerId[{$partnerId}], externalStorage id[" . $externalStorage->getId() . "], fileSync id[" . $fileSync->getId() . "], srcFileSyncLocalPath[{$srcFileSyncLocalPath}]"); $netStorageExportData = new kStorageExportJobData(); $netStorageExportData->setServerUrl($externalStorage->getStorageUrl()); $netStorageExportData->setServerUsername($externalStorage->getStorageUsername()); $netStorageExportData->setServerPassword($externalStorage->getStoragePassword()); $netStorageExportData->setFtpPassiveMode($externalStorage->getStorageFtpPassiveMode()); $netStorageExportData->setSrcFileSyncLocalPath($srcFileSyncLocalPath); $netStorageExportData->setSrcFileSyncId($fileSync->getId()); $netStorageExportData->setForce($force); $netStorageExportData->setDestFileSyncStoredPath($externalStorage->getStorageBaseDir() . '/' . $fileSync->getFilePath()); $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild(false); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($entryId); $batchJob->setPartnerId($partnerId); } $batchJob->setDc($dc); KalturaLog::log("Creating Storage export job, with source file: " . $netStorageExportData->getSrcFileSyncLocalPath()); return self::addJob($batchJob, $netStorageExportData, BatchJobType::STORAGE_EXPORT, $externalStorage->getProtocol()); }