Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUP-20262: increase process timeout to 20 min for entries > 2GB #9131

Merged
merged 6 commits into from
Jan 28, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class YoutubeApiDistributionEngine extends DistributionEngine implements
{
protected $tempXmlPath;
protected $timeout = 90;
protected $processedTimeout = 300;
protected $processedTimeout = 300;
protected $longProcessedTimeout = 1200;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to use this default values if they are not set in configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set both properties on the class, then we either override them from config (if config exist) otherwise we keep the default values defined on class.

protected $processedTimeout = 300;
protected $longProcessedTimeout = 1200;

Let me know if I confused it.

protected $bigFile = 2147483648;
Comment on lines +33 to +35
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MosheMaorKaltura default values


/* (non-PHPdoc)
* @see DistributionEngine::configure()
Expand Down Expand Up @@ -261,10 +263,13 @@ protected function doSubmit(KalturaDistributionSubmitJobData $data, KalturaYoutu
$client->setDefer(true);
$request = $youtube->videos->insert("status,snippet", $video);

$fileSize = kFile::fileSize($videoPath);

$media = new Google_Http_MediaFileUpload($client, $request, 'video/*', null, true, self::DEFAULT_CHUNK_SIZE_BYTE);
$media->setFileSize(filesize($videoPath));
$media->setFileSize($fileSize);
$ingestedVideo = self::uploadInChunks($media,$videoPath, self::DEFAULT_CHUNK_SIZE_BYTE);
$client->setDefer(false);
$this->setLongProcessedTimeout($fileSize);

$data->remoteId = $ingestedVideo->getId();

Expand Down Expand Up @@ -682,5 +687,29 @@ private static function uploadChunk($media, $chunk)

}

/**
* @param int $fileSize
*/
protected function setLongProcessedTimeout($fileSize)
{
if (isset(KBatchBase::$taskConfig->params->youtubeApi))
{
if (isset(KBatchBase::$taskConfig->params->youtubeApi->longProcessedTimeout))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use {} for every if

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
$this->longProcessedTimeout = KBatchBase::$taskConfig->params->youtubeApi->longProcessedTimeout;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If value is not set in the configuration file - supply default value hard coded

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default values set lines 33-35

}

if (isset(KBatchBase::$taskConfig->params->youtubeApi->bigFile))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - if no value , then set default hard coded.

{
$this->bigFile = KBatchBase::$taskConfig->params->youtubeApi->bigFile;
}
}

if ($fileSize > $this->bigFile)
{
$this->processedTimeout = $this->longProcessedTimeout;
KalturaLog::info('Increased processed timeout to '.$this->processedTimeout.' seconds for file larger than ' . $this->bigFile);
}
}

}