本文整理汇总了PHP中kDataCenterMgr::getCurrentDcId方法的典型用法代码示例。如果您正苦于以下问题:PHP kDataCenterMgr::getCurrentDcId方法的具体用法?PHP kDataCenterMgr::getCurrentDcId怎么用?PHP kDataCenterMgr::getCurrentDcId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kDataCenterMgr
的用法示例。
在下文中一共展示了kDataCenterMgr::getCurrentDcId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadFileToToken
/**
* Upload a file to the current upload token
* @param file $fileData
* @param bool $resume
* @param bool $finalChunk
* @param int $resumeAt
*/
public function uploadFileToToken($fileData, $resume = false, $finalChunk = true, $resumeAt = -1)
{
$allowedStatuses = array(UploadToken::UPLOAD_TOKEN_PENDING, UploadToken::UPLOAD_TOKEN_PARTIAL_UPLOAD);
if (!in_array($this->_uploadToken->getStatus(), $allowedStatuses, true)) {
throw new kUploadTokenException("Invalid upload token status", kUploadTokenException::UPLOAD_TOKEN_INVALID_STATUS);
}
$this->updateFileName($fileData);
try {
$this->checkIfFileIsValid($fileData);
} catch (kUploadTokenException $ex) {
if (!$resume && $finalChunk) {
kFlowHelper::handleUploadFailed($this->_uploadToken);
}
$this->tryMoveToErrors($fileData);
throw $ex;
}
if ($resume) {
$this->handleResume($fileData, $resumeAt);
} else {
$this->handleMoveFile($fileData);
}
$fileSize = kFile::fileSize($this->_uploadToken->getUploadTempPath());
if ($finalChunk) {
$this->_uploadToken->setStatus(UploadToken::UPLOAD_TOKEN_FULL_UPLOAD);
} else {
$this->_uploadToken->setStatus(UploadToken::UPLOAD_TOKEN_PARTIAL_UPLOAD);
}
$this->_uploadToken->setUploadedFileSize($fileSize);
$this->_uploadToken->setDc(kDataCenterMgr::getCurrentDcId());
$this->_uploadToken->save();
$this->addTrackEntry();
}
示例2: toObject
public function toObject($object_to_fill = null, $props_to_skip = array())
{
$this->validateForUsage($object_to_fill, $props_to_skip);
$dbUploadToken = UploadTokenPeer::retrieveByPK($this->token);
if (is_null($dbUploadToken)) {
throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_NOT_FOUND);
}
if (!$object_to_fill) {
$object_to_fill = new kUploadedFileTokenResource();
}
$object_to_fill->setToken($this->token);
if ($dbUploadToken->getStatus() != UploadToken::UPLOAD_TOKEN_FULL_UPLOAD) {
$object_to_fill->setIsReady(false);
return $object_to_fill;
}
try {
$entryFullPath = kUploadTokenMgr::getFullPathByUploadTokenId($this->token);
} catch (kCoreException $ex) {
if ($ex->getCode() == kUploadTokenException::UPLOAD_TOKEN_INVALID_STATUS) {
}
throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY);
throw $ex;
}
if (!file_exists($entryFullPath)) {
$remoteDCHost = kUploadTokenMgr::getRemoteHostForUploadToken($this->token, kDataCenterMgr::getCurrentDcId());
if ($remoteDCHost) {
kFileUtils::dumpApiRequest($remoteDCHost);
} else {
throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
}
}
$object_to_fill->setLocalFilePath($entryFullPath);
return $object_to_fill;
}
示例3: shouldConsumeAddedEvent
public function shouldConsumeAddedEvent(BaseObject $object)
{
if ($object instanceof FileSync && $object->getStatus() == FileSync::FILE_SYNC_STATUS_PENDING && $object->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_FILE && $object->getDc() != kDataCenterMgr::getCurrentDcId() && $this->shouldSyncFileObjectType($object->getObjectType(), $object->getObjectSubType())) {
return true;
}
return false;
}
示例4: createPeriodicSyncPoints
/**
* Creates perioding metadata sync-point events on a live stream
*
* @action createPeriodicSyncPoints
* @actionAlias liveStream.createPeriodicSyncPoints
* @param string $entryId Kaltura live-stream entry id
* @param int $interval Events interval in seconds
* @param int $duration Duration in seconds
*
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
* @throws KalturaErrors::NO_MEDIA_SERVER_FOUND
* @throws KalturaErrors::MEDIA_SERVER_SERVICE_NOT_FOUND
*/
function createPeriodicSyncPoints($entryId, $interval, $duration)
{
$entryDc = substr($entryId, 0, 1);
if ($entryDc != kDataCenterMgr::getCurrentDcId()) {
$remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($entryDc);
kFileUtils::dumpApiRequest($remoteDCHost, true);
}
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::LIVE_STREAM || !in_array($dbEntry->getSource(), array(KalturaSourceType::LIVE_STREAM, KalturaSourceType::LIVE_STREAM_ONTEXTDATA_CAPTIONS))) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
/* @var $dbEntry LiveStreamEntry */
$mediaServers = $dbEntry->getMediaServers();
if (!count($mediaServers)) {
throw new KalturaAPIException(KalturaErrors::NO_MEDIA_SERVER_FOUND, $entryId);
}
foreach ($mediaServers as $key => $kMediaServer) {
if ($kMediaServer && $kMediaServer instanceof kLiveMediaServer) {
$mediaServer = $kMediaServer->getMediaServer();
$mediaServerCuePointsService = $mediaServer->getWebService(MediaServer::WEB_SERVICE_CUE_POINTS);
KalturaLog::debug("Sending sync points for DC [" . $mediaServer->getDc() . "] ");
if ($mediaServerCuePointsService && $mediaServerCuePointsService instanceof KalturaMediaServerCuePointsService) {
KalturaLog::debug("Call createTimeCuePoints on DC [" . $mediaServer->getDc() . "] ");
$mediaServerCuePointsService->createTimeCuePoints($entryId, $interval, $duration);
} else {
KalturaLog::debug("Media server service not found on DC: [" . $mediaServer->getDc() . "] ");
}
}
}
}
示例5: validateEntry
public function validateEntry(entry $dbEntry)
{
parent::validateEntry($dbEntry);
$this->validatePropertyNotNull('resources');
$dc = null;
foreach ($this->resources as $resource) {
$resource->validateEntry($dbEntry);
if (!$resource instanceof KalturaDataCenterContentResource) {
continue;
}
$theDc = $resource->getDc();
if (is_null($theDc)) {
continue;
}
if (is_null($dc)) {
$dc = $theDc;
} elseif ($dc != $theDc) {
throw new KalturaAPIException(KalturaErrors::RESOURCES_MULTIPLE_DATA_CENTERS);
}
}
if (!is_null($dc) && $dc != kDataCenterMgr::getCurrentDcId()) {
$remoteHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($dc);
kFileUtils::dumpApiRequest($remoteHost);
}
}
示例6: objectAdded
/**
* @param BaseObject $object
* @return bool true if should continue to the next consumer
*/
public function objectAdded(BaseObject $object)
{
if (!$object instanceof FileSync || $object->getStatus() != FileSync::FILE_SYNC_STATUS_PENDING || $object->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_FILE || $object->getDc() == kDataCenterMgr::getCurrentDcId()) {
return true;
}
$c = new Criteria();
$c->addAnd(FileSyncPeer::OBJECT_ID, $object->getObjectId());
$c->addAnd(FileSyncPeer::VERSION, $object->getVersion());
$c->addAnd(FileSyncPeer::OBJECT_TYPE, $object->getObjectType());
$c->addAnd(FileSyncPeer::OBJECT_SUB_TYPE, $object->getObjectSubType());
$c->addAnd(FileSyncPeer::ORIGINAL, '1');
$original_filesync = FileSyncPeer::doSelectOne($c);
if (!$original_filesync) {
KalturaLog::err('Original filesync not found for object_id[' . $object->getObjectId() . '] version[' . $object->getVersion() . '] type[' . $object->getObjectType() . '] subtype[' . $object->getObjectSubType() . ']');
return true;
}
$sourceFileUrl = $original_filesync->getExternalUrl();
if (!$sourceFileUrl) {
KalturaLog::err('External URL not found for filesync id [' . $object->getId() . ']');
return true;
}
$job = kMultiCentersManager::addFileSyncImportJob($this->getEntryId($object), $object->getPartnerId(), $object->getId(), $sourceFileUrl);
$job->setDc($object->getDc());
$job->save();
return true;
}
示例7: preInsert
public function preInsert(PropelPDO $con = null)
{
if ($this->getPartnerId() === Partner::MEDIA_SERVER_PARTNER_ID) {
$this->setDc(kDataCenterMgr::getCurrentDcId());
}
return parent::preInsert($con);
}
示例8: retrieveByLocalServer
/**
* Retrieve the server object of the current data center
*
* @param string $server server name
* @param PropelPDO $con the connection to use
* @return SphinxLogServer
*/
public static function retrieveByLocalServer($server, PropelPDO $con = null)
{
$criteria = new Criteria();
$criteria->add(SphinxLogServerPeer::SERVER, $server);
$criteria->add(SphinxLogServerPeer::DC, kDataCenterMgr::getCurrentDcId());
return SphinxLogServerPeer::doSelectOne($criteria, $con);
}
示例9: toObject
public function toObject($object_to_fill = null, $props_to_skip = array())
{
if (!$this->isNull('currentDc')) {
$this->dcEqual = kDataCenterMgr::getCurrentDcId();
}
return parent::toObject($object_to_fill, $props_to_skip);
}
示例10: balanceJobsload
/**
* Entry point to job balancing.
* - Move jobs from status '0' to status '11' in case there are too many pending jobs
* - move jobs back from status '11' to status '0' in case the load is over.
*
*/
public static function balanceJobsload()
{
$minPendingJobs = self::getSuspenderMinPendingJobs();
$maxPendingJobs = self::getSuspenderMaxPendingJobs();
$dcId = kDataCenterMgr::getCurrentDcId();
$loadedKeys = array();
// Suspend Jobs
$c = self::createJobBalanceQuery($dcId, $minPendingJobs);
$stmt = BatchJobLockPeer::doSelectStmt($c);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
$partnerId = $row['PARTNER_ID'];
$jobType = $row['JOB_TYPE'];
$jobSubType = $row['JOB_SUB_TYPE'];
$loadedKeys[] = $partnerId . "#" . $jobType . "#" . $jobSubType;
$jobCount = $row[BatchJobLockPeer::COUNT];
if ($jobCount > $maxPendingJobs) {
self::suspendJobs($jobCount - $maxPendingJobs, $dcId, $partnerId, $jobType, $jobSubType);
}
}
// Unsuspend jobs
$c = self::createReturnBalancedJobsQuery($dcId);
$stmt = BatchJobLockSuspendPeer::doSelectStmt($c);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
$partnerId = $row['PARTNER_ID'];
$jobType = $row['JOB_TYPE'];
$jobSubType = $row['JOB_SUB_TYPE'];
$key = $partnerId . "#" . $jobType . "#" . $jobSubType;
if (!in_array($key, $loadedKeys)) {
self::unsuspendJobs($maxPendingJobs - $minPendingJobs, $dcId, $partnerId, $jobType, $jobSubType);
}
}
}
示例11: save
public function save(PropelPDO $con = null)
{
KalturaLog::log("BatchJob [{$this->getJobType()}][{$this->getJobSubType()}]: save()");
$is_new = $this->isNew();
if ($this->isNew()) {
$this->setDc(kDataCenterMgr::getCurrentDcId());
// if the status not set upon creation
if (is_null($this->status) || !$this->isColumnModified(BatchJobPeer::STATUS)) {
//echo "sets the status to " . self::BATCHJOB_STATUS_PENDING . "\n";
$this->setStatus(self::BATCHJOB_STATUS_PENDING);
}
}
$res = parent::save($con);
if ($is_new && !$this->root_job_id && $this->id) {
// set the root to point to itself
$this->setRootJobId($this->id);
$res = parent::save($con);
}
/*
* remove - no need to use file indicators any more
// when new object or status is pending - add the indicator for the batch job to start running
if ( $is_new || ( $this->getStatus() == self::BATCHJOB_STATUS_PENDING ) )
{
self::addIndicator( $this->getId() , $this->getJobType() );
KalturaLog::log ( "BatchJob: Added indicator for BatchJob [" . $this->getId() . "] of type [{$this->getJobType() }]" );
//debugUtils::st();
}
else
{
KalturaLog::log ( "BatchJob: Didn't add an indicator for BatchJob [" . $this->getId() . "]" );
}
*/
return $res;
}
示例12: retrieveByFileSyncKey
/**
*
* @param FileSyncKey $key
* @return FileSync
*/
public static function retrieveByFileSyncKey(FileSyncKey $key, $current_dc_only = false)
{
$c = self::getCriteriaForFileSyncKey($key);
if ($current_dc_only) {
$c->add(self::DC, kDataCenterMgr::getCurrentDcId());
}
return self::doSelectOne($c);
}
示例13: dumpApiRequest
function dumpApiRequest($entryId, $onlyIfAvailable = true)
{
$entryDc = substr($entryId, 0, 1);
if ($entryDc != kDataCenterMgr::getCurrentDcId()) {
$remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($entryDc);
kFileUtils::dumpApiRequest($remoteDCHost, $onlyIfAvailable);
}
}
示例14: save
public function save(PropelPDO $con = null)
{
if ($this->isNew()) {
$this->setId($this->calculateId());
$this->setDc(kDataCenterMgr::getCurrentDcId());
}
parent::save($con);
}
示例15: toObject
public function toObject($object_to_fill = null, $props_to_skip = array())
{
if (!$this->isNull('currentDc')) {
if ($this->currentDc == KalturaNullableBoolean::TRUE_VALUE) {
$this->dcEqual = kDataCenterMgr::getCurrentDcId();
}
}
return parent::toObject($object_to_fill, $props_to_skip);
}