private function closeConvert(KalturaBatchJob $job, KalturaConvertJobData $data) { if ($job->queueTime + self::$taskConfig->params->maxTimeBeforeFail < time()) { return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::CLOSER_TIMEOUT, 'Timed out', KalturaBatchJobStatus::FAILED); } if (isset($data->flavorParamsOutputId)) { $data->flavorParamsOutput = self::$kClient->flavorParamsOutput->get($data->flavorParamsOutputId); } $this->operationEngine = KOperationManager::getEngine($job->jobSubType, $data, $job); try { $isDone = $this->operationEngine->closeOperation(); if (!$isDone) { $message = "Conversion close in process. "; if ($this->operationEngine->getMessage()) { $message = $message . $this->operationEngine->getMessage(); } return $this->closeJob($job, null, null, $message, KalturaBatchJobStatus::ALMOST_DONE, $data); } } catch (KOperationEngineException $e) { $err = "engine [" . get_class($this->operationEngine) . "] convert closer failed: " . $e->getMessage(); return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::CONVERSION_FAILED, $err, KalturaBatchJobStatus::FAILED); } if (self::$taskConfig->params->isRemoteOutput) { return $this->handleRemoteOutput($job, $data); } else { return $this->closeJob($job, null, null, "Conversion finished", KalturaBatchJobStatus::FINISHED, $data); } }
protected function convert(KalturaBatchJob $job, KalturaConvartableJobData $data) { /* * When called for 'collections', the 'flavorParamsOutputId' is not set. * It is set in the 'flavors' array, but for collections the 'flavorParamsOutput' it is unrequired. */ if (isset($data->flavorParamsOutputId)) { $data->flavorParamsOutput = self::$kClient->flavorParamsOutput->get($data->flavorParamsOutputId); } foreach ($data->srcFileSyncs as $srcFileSyncDescriptor) { $srcFileSyncDescriptor->actualFileSyncLocalPath = $this->translateSharedPath2Local($srcFileSyncDescriptor->fileSyncLocalPath); } $updateData = new KalturaConvartableJobData(); $updateData->srcFileSyncs = $data->srcFileSyncs; $job = $this->updateJob($job, null, KalturaBatchJobStatus::QUEUED, $updateData); // creates a temp file path // $uniqid = uniqid("convert_{$job->entryId}_"); $uniqid = uniqid(); $uniqid = "convert_{$job->entryId}_" . substr($uniqid, -5); $data->destFileSyncLocalPath = $this->localTempPath . DIRECTORY_SEPARATOR . $uniqid; $this->operationEngine = KOperationManager::getEngine($job->jobSubType, $data, $job); if ($this->operationEngine == null) { $err = "Cannot find operation engine [{$job->jobSubType}] for job id [{$job->id}]"; return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::ENGINE_NOT_FOUND, $err, KalturaBatchJobStatus::FAILED); } KalturaLog::info("Using engine: " . get_class($this->operationEngine)); return $this->convertImpl($job, $data); }
protected function convert(KalturaBatchJob $job, KalturaConvartableJobData $data) { if ($this->taskConfig->params->isRemote) { $job->lastWorkerRemote = true; } $data->actualSrcFileSyncLocalPath = $this->translateSharedPath2Local($data->srcFileSyncLocalPath); $updateData = new KalturaConvartableJobData(); $updateData->actualSrcFileSyncLocalPath = $data->actualSrcFileSyncLocalPath; $job = $this->updateJob($job, null, KalturaBatchJobStatus::QUEUED, 1, $updateData, $job->lastWorkerRemote); // creates a temp file path // $uniqid = uniqid("convert_{$job->entryId}_"); $uniqid = uniqid(); $uniqid = "convert_{$job->entryId}_" . substr($uniqid, -5); $data->destFileSyncLocalPath = "{$this->localTempPath}/{$uniqid}"; $this->operationEngine = KOperationManager::getEngine($job->jobSubType, $this->taskConfig, $data); if ($this->operationEngine == null) { $err = "Cannot find operation engine [{$job->jobSubType}] for job id [{$job->id}]"; return $this->closeJob($job, KalturaBatchJobErrorTypes::APP, KalturaBatchJobAppErrors::ENGINE_NOT_FOUND, $err, KalturaBatchJobStatus::FAILED); } KalturaLog::info("Using engine: " . get_class($this->operationEngine)); return $this->convertImpl($job, $data); }