public function __construct($cmd, $outFilePath)
 {
     parent::__construct($cmd);
     $this->outFilesPath[] = $outFilePath;
     $this->outFilePath = $outFilePath;
     $this->logFilePath = "{$outFilePath}.log";
 }
 protected function __construct($userId, $userKey, $url)
 {
     parent::__construct();
     $this->userId = $userId;
     $this->userKey = $userKey;
     $this->url = $url;
 }
示例#3
0
 protected function convertJob(KalturaBatchJob $job, KalturaConvertJobData $data)
 {
     KalturaLog::info("Converting flavor job");
     // ASSUME:
     // 1. full input file path ($data->actualSrcFileSyncLocalPath)
     // 2. flavorParams ($data->flavorParams)
     // PROMISE
     // 1. full output file path ($data->destFileSyncLocalPath)
     // 2. full output log path
     // 3. in case of remote engine (almost done) - id/url to query result
     if ($job->executionAttempts > 1) {
         if (strlen($data->destFileSyncLocalPath) && file_exists($data->destFileSyncLocalPath)) {
             return $this->moveFile($job, $data);
         }
     }
     if ($this->taskConfig->params->isRemote || !strlen(trim($data->actualSrcFileSyncLocalPath))) {
         if (!strlen(trim($data->actualSrcFileSyncLocalPath))) {
             $data->actualSrcFileSyncLocalPath = $this->taskConfig->params->localFileRoot . DIRECTORY_SEPARATOR . basename($data->srcFileSyncRemoteUrl);
         }
         $err = null;
         if (!$this->distributedFileManager->getLocalPath($data->actualSrcFileSyncLocalPath, $data->srcFileSyncRemoteUrl, $err)) {
             if (!$err) {
                 $err = 'Failed to translate url to local path';
             }
             return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::REMOTE_FILE_NOT_FOUND, $err, KalturaBatchJobStatus::RETRY);
         }
     }
     if (!file_exists($data->actualSrcFileSyncLocalPath)) {
         return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::NFS_FILE_DOESNT_EXIST, "Source file {$data->actualSrcFileSyncLocalPath} does not exist", KalturaBatchJobStatus::RETRY);
     }
     if (!is_file($data->actualSrcFileSyncLocalPath)) {
         return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::NFS_FILE_DOESNT_EXIST, "Source file {$data->actualSrcFileSyncLocalPath} is not a file", KalturaBatchJobStatus::FAILED);
     }
     $data->logFileSyncLocalPath = "{$data->destFileSyncLocalPath}.log";
     $monitorFiles = array($data->logFileSyncLocalPath);
     $this->startMonitor($monitorFiles);
     $operator = $this->getOperator($data);
     try {
         $this->operationEngine->operate($operator, $data->actualSrcFileSyncLocalPath);
     } catch (KOperationEngineException $e) {
         if ($job->jobSubType == KalturaConversionEngineType::ENCODING_COM || $job->jobSubType == KalturaConversionEngineType::KALTURA_COM) {
             $log = $this->operationEngine->getLogData();
             if ($log && strlen($log)) {
                 $this->kClient->batch->logConversion($data->flavorAssetId, $log);
             }
         }
         $err = "engine [" . get_class($this->operationEngine) . "] converted failed: " . $e->getMessage();
         return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::CONVERSION_FAILED, $err, KalturaBatchJobStatus::FAILED);
     }
     $this->stopMonitor();
     if ($job->jobSubType == KalturaConversionEngineType::ENCODING_COM || $job->jobSubType == KalturaConversionEngineType::KALTURA_COM) {
         $msg = $this->operationEngine->getMessage();
         $msg = "engine [" . get_class($this->operationEngine) . "] converted successfully: {$msg}";
         return $this->closeJob($job, null, null, $msg, KalturaBatchJobStatus::ALMOST_DONE, $data);
     }
     $job = $this->updateJob($job, "engine [" . get_class($this->operationEngine) . "] converted successfully", KalturaBatchJobStatus::MOVEFILE, 90, $data);
     return $this->moveFile($job, $data);
 }
 protected function doOperation()
 {
     parent::doOperation();
     $this->parseCreatedFiles();
     foreach ($this->outFilesPath as $outFile) {
         $this->addToLogFile("media info [{$outFile}]");
         $this->logMediaInfo($outFile);
     }
 }
示例#5
0
 protected function convertJob(KalturaBatchJob $job, KalturaConvertJobData $data)
 {
     KalturaLog::info("Converting flavor job");
     // ASSUME:
     // 1. full input file path for each ($data->srcFileSyncs actualFileSyncLocalPath)
     // 2. flavorParams ($data->flavorParams)
     // PROMISE
     // 1. full output file path ($data->destFileSyncLocalPath)
     // 2. full output log path
     // 3. in case of remote engine (almost done) - id/url to query result
     // TODO: need to verify that this part can be removed
     //		if($job->executionAttempts > 1) // is a retry
     //		{
     //			if(strlen($data->destFileSyncLocalPath) && file_exists($data->destFileSyncLocalPath))
     //			{
     //				return $this->moveFile($job, $data);
     //			}
     //		}
     foreach ($data->srcFileSyncs as $srcFileSyncDescriptor) {
         if (self::$taskConfig->params->isRemoteInput || !strlen(trim($srcFileSyncDescriptor->actualFileSyncLocalPath))) {
             if (!strlen(trim($srcFileSyncDescriptor->actualFileSyncLocalPath))) {
                 $srcFileSyncDescriptor->actualFileSyncLocalPath = self::$taskConfig->params->localFileRoot . DIRECTORY_SEPARATOR . basename($srcFileSyncDescriptor->fileSyncRemoteUrl);
             }
             $err = null;
             if (!$this->distributedFileManager->getLocalPath($srcFileSyncDescriptor->actualFileSyncLocalPath, $srcFileSyncDescriptor->fileSyncRemoteUrl, $err)) {
                 if (!$err) {
                     $err = 'Failed to translate url to local path';
                 }
                 return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::REMOTE_FILE_NOT_FOUND, $err, KalturaBatchJobStatus::RETRY);
             }
         }
         if (!$data->flavorParamsOutput->sourceRemoteStorageProfileId) {
             if (!file_exists($srcFileSyncDescriptor->actualFileSyncLocalPath)) {
                 return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::NFS_FILE_DOESNT_EXIST, "Source file {$srcFileSyncDescriptor->actualFileSyncLocalPath} does not exist", KalturaBatchJobStatus::RETRY);
             }
             if (!is_file($srcFileSyncDescriptor->actualFileSyncLocalPath)) {
                 return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::NFS_FILE_DOESNT_EXIST, "Source file {$srcFileSyncDescriptor->actualFileSyncLocalPath} is not a file", KalturaBatchJobStatus::FAILED);
             }
         }
     }
     $data->logFileSyncLocalPath = "{$data->destFileSyncLocalPath}.log";
     $monitorFiles = array($data->logFileSyncLocalPath);
     $this->startMonitor($monitorFiles);
     $operator = $this->getOperator($data);
     try {
         $actualFileSyncLocalPath = null;
         $srcFileSyncDescriptor = reset($data->srcFileSyncs);
         if ($srcFileSyncDescriptor) {
             $actualFileSyncLocalPath = $srcFileSyncDescriptor->actualFileSyncLocalPath;
         }
         //TODO: in future remove the inFilePath parameter from operate method, the input files passed to operation
         //engine as part of the data
         $isDone = $this->operationEngine->operate($operator, $actualFileSyncLocalPath);
         $data = $this->operationEngine->getData();
         //get the data from operation engine for the cases it was changed
         $this->stopMonitor();
         $jobMessage = "engine [" . get_class($this->operationEngine) . "] converted successfully. ";
         if (!$isDone) {
             return $this->closeJob($job, null, null, $jobMessage, KalturaBatchJobStatus::ALMOST_DONE, $data);
         } else {
             $job = $this->updateJob($job, $jobMessage, KalturaBatchJobStatus::MOVEFILE, $data);
             return $this->moveFile($job, $data);
         }
     } catch (Exception $e) {
         $data = $this->operationEngine->getData();
         $log = $this->operationEngine->getLogData();
         //removing unsuported XML chars
         $log = preg_replace('/[^\\t\\n\\r\\x{20}-\\x{d7ff}\\x{e000}-\\x{fffd}\\x{10000}-\\x{10ffff}]/u', '', $log);
         if ($log && strlen($log)) {
             try {
                 self::$kClient->batch->logConversion($data->flavorAssetId, $log);
             } catch (Exception $ee) {
                 KalturaLog::err("Log conversion: " . $ee->getMessage());
             }
         }
         $err = "engine [" . get_class($this->operationEngine) . "] converted failed: " . $e->getMessage();
         if ($e instanceof KOperationEngineException) {
             return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::CONVERSION_FAILED, $err, KalturaBatchJobStatus::FAILED, $data);
         }
         //if this is not the usual KOperationEngineException, pass the Exception
         throw $e;
     }
 }