예제 #1
0
 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;
 }
 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
0
 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);
 }
예제 #4
0
 public function preInsert(PropelPDO $con = null)
 {
     if ($this->getPartnerId() === Partner::MEDIA_SERVER_PARTNER_ID) {
         $this->setDc(kDataCenterMgr::getCurrentDcId());
     }
     return parent::preInsert($con);
 }
예제 #5
0
 /**
  * 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);
         }
     }
 }
 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);
     }
 }
예제 #7
0
 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;
 }
예제 #8
0
 /**
  * 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() . "] ");
             }
         }
     }
 }
예제 #9
0
 /**
  * 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);
 }
예제 #10
0
 protected static function getStorageProfile($storageProfileId = null)
 {
     if (is_null($storageProfileId)) {
         return kDataCenterMgr::getCurrentStorageProfile();
     }
     return StorageProfilePeer::retrieveByPK($storageProfileId);
 }
예제 #11
0
 /**
  * @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;
 }
예제 #12
0
 /**
  * 
  * @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
0
 function dumpApiRequest($entryId, $onlyIfAvailable = true)
 {
     $entryDc = substr($entryId, 0, 1);
     if ($entryDc != kDataCenterMgr::getCurrentDcId()) {
         $remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($entryDc);
         kFileUtils::dumpApiRequest($remoteDCHost, $onlyIfAvailable);
     }
 }
예제 #14
0
 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);
 }
 public function getDc()
 {
     $content = myContentStorage::getFSContentRootPath();
     $entryFullPath = "{$content}/content/webcam/{$this->token}.flv";
     if (file_exists($entryFullPath)) {
         return kDataCenterMgr::getCurrentDcId();
     }
     return 1 - kDataCenterMgr::getCurrentDcId();
     // other dc
 }
예제 #16
0
 /**
  * Serves multiple files for synchronization between datacenters 
  */
 public function execute()
 {
     $fileSyncIds = $this->getRequestParameter("ids");
     $hash = $this->getRequestParameter("hash");
     // validate hash
     $currentDc = kDataCenterMgr::getCurrentDc();
     $currentDcId = $currentDc["id"];
     $expectedHash = md5($currentDc["secret"] . $fileSyncIds);
     if ($hash !== $expectedHash) {
         $error = "Invalid hash - ids [{$fileSyncIds}] got [{$hash}] expected [{$expectedHash}]";
         KalturaLog::err($error);
         KExternalErrors::dieError(KExternalErrors::INVALID_TOKEN);
     }
     // load file syncs
     $fileSyncs = FileSyncPeer::retrieveByPks(explode(',', $fileSyncIds));
     if ($fileSyncs) {
         KalturaMonitorClient::initApiMonitor(false, 'extwidget.serveMultiFile', $fileSyncs[0]->getPartnerId());
     }
     // resolve file syncs
     $filePaths = array();
     foreach ($fileSyncs as $fileSync) {
         if ($fileSync->getDc() != $currentDcId) {
             $error = "FileSync id [" . $fileSync->getId() . "] does not belong to this DC";
             KalturaLog::err($error);
             KExternalErrors::dieError(KExternalErrors::BAD_QUERY);
         }
         // resolve if file_sync is link
         $fileSyncResolved = kFileSyncUtils::resolve($fileSync);
         // check if file sync path leads to a file or a directory
         $resolvedPath = $fileSyncResolved->getFullPath();
         if (is_dir($resolvedPath)) {
             $error = "FileSync id [" . $fileSync->getId() . "] is a directory";
             KalturaLog::err($error);
             KExternalErrors::dieError(KExternalErrors::BAD_QUERY);
         }
         if (!file_exists($resolvedPath)) {
             $error = "Path [{$resolvedPath}] for fileSync id [" . $fileSync->getId() . "] does not exist";
             KalturaLog::err($error);
             continue;
         }
         $filePaths[$fileSync->getId()] = $resolvedPath;
     }
     $boundary = md5(uniqid('', true));
     header('Content-Type: multipart/form-data; boundary=' . $boundary);
     foreach ($filePaths as $id => $filePath) {
         echo "--{$boundary}\n";
         echo "Content-Type: application/octet-stream\n";
         echo "Content-Disposition: form-data; name=\"{$id}\"\n\n";
         readfile($filePath);
         echo "\n";
     }
     echo "--{$boundary}--\n";
     KExternalErrors::dieGracefully();
 }
예제 #17
0
 public static function validateKs($job)
 {
     $dcParams = kDataCenterMgr::getCurrentDc();
     $token = $dcParams["secret"];
     $createdString = md5($job->getId() . $token);
     $ks = kCurrentContext::$ks_object;
     if ($createdString == $ks->additional_data) {
         return true;
     }
     return false;
 }
 private static function calculateId()
 {
     $dc = kDataCenterMgr::getCurrentDc();
     for ($i = 0; $i < 10; ++$i) {
         $id = $dc["id"] . '_' . kString::generateStringId();
         $existing_object = entryPeer::retrieveByPk($id);
         if (!$existing_object) {
             return $id;
         }
     }
     die;
 }
 /**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     requestUtils::handleConditionalGet();
     $file_sync_id = $this->getRequestParameter("id");
     $hash = $this->getRequestParameter("hash");
     $file_name = $this->getRequestParameter("fileName");
     if ($file_name) {
         $file_name = base64_decode($file_name);
     }
     kDataCenterMgr::serveFileToRemoteDataCenter($file_sync_id, $hash, $file_name);
     die;
 }
예제 #20
0
 public function calculateId()
 {
     $dc = kDataCenterMgr::getCurrentDc();
     for ($i = 0; $i < 10; $i++) {
         $id = $dc["id"] . '_' . md5(microtime(true));
         $existingObject = UploadTokenPeer::retrieveByPk($id);
         if (!$existingObject) {
             return $id;
         }
     }
     throw new Exception("Could not calculate unique id for upload token");
 }
예제 #21
0
 /**
  * Generic add entry using an uploaded file, should be used when the uploaded entry type is not known
  *
  * @action addFromUploadedFile
  * @param KalturaBaseEntry $entry
  * @param string $uploadTokenId
  * @param KalturaEntryType $type
  * @return KalturaBaseEntry
  */
 function addFromUploadedFileAction(KalturaBaseEntry $entry, $uploadTokenId, $type = -1)
 {
     try {
         // check that the uploaded file exists
         $entryFullPath = kUploadTokenMgr::getFullPathByUploadTokenId($uploadTokenId);
     } 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($uploadTokenId, kDataCenterMgr::getCurrentDcId());
         if ($remoteDCHost) {
             kFile::dumpApiRequest($remoteDCHost);
         } else {
             throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
         }
     }
     // validate the input object
     //$entry->validatePropertyMinLength("name", 1);
     if (!$entry->name) {
         $entry->name = $this->getPartnerId() . '_' . time();
     }
     // first copy all the properties to the db entry, then we'll check for security stuff
     $dbEntry = $entry->toInsertableObject(new entry());
     $dbEntry->setType($type);
     $dbEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_AUTOMATIC);
     $this->checkAndSetValidUser($entry, $dbEntry);
     $this->checkAdminOnlyInsertProperties($entry);
     $this->validateAccessControlId($entry);
     $this->validateEntryScheduleDates($entry);
     $dbEntry->setPartnerId($this->getPartnerId());
     $dbEntry->setSubpId($this->getPartnerId() * 100);
     $dbEntry->setSourceId($uploadTokenId);
     $dbEntry->setSourceLink($entryFullPath);
     $dbEntry->setDefaultModerationStatus();
     $dbEntry->save();
     $kshow = $this->createDummyKShow();
     $kshowId = $kshow->getId();
     myEntryUtils::setEntryTypeAndMediaTypeFromFile($dbEntry, $entryFullPath);
     // setup the needed params for my insert entry helper
     $paramsArray = array("entry_media_source" => KalturaSourceType::FILE, "entry_media_type" => $dbEntry->getMediaType(), "entry_full_path" => $entryFullPath, "entry_license" => $dbEntry->getLicenseType(), "entry_credit" => $dbEntry->getCredit(), "entry_source_link" => $dbEntry->getSourceLink(), "entry_tags" => $dbEntry->getTags());
     $token = $this->getKsUniqueString();
     $insert_entry_helper = new myInsertEntryHelper(null, $dbEntry->getKuserId(), $kshowId, $paramsArray);
     $insert_entry_helper->setPartnerId($this->getPartnerId(), $this->getPartnerId() * 100);
     $insert_entry_helper->insertEntry($token, $dbEntry->getType(), $dbEntry->getId(), $dbEntry->getName(), $dbEntry->getTags(), $dbEntry);
     $dbEntry = $insert_entry_helper->getEntry();
     kUploadTokenMgr::closeUploadTokenById($uploadTokenId);
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry);
     $entry->fromObject($dbEntry);
     return $entry;
 }
 public function getDc()
 {
     $content = myContentStorage::getFSContentRootPath();
     $entryFullPaths = array("{$content}/content/webcam/{$this->token}.flv", "{$content}/content/webcam/{$this->token}.f4v", "{$content}/content/webcam/{$this->token}.f4v.mp4");
     foreach ($entryFullPaths as $entryFullPath) {
         if (file_exists($entryFullPath)) {
             return kDataCenterMgr::getCurrentDcId();
         }
     }
     return 1 - kDataCenterMgr::getCurrentDcId();
     // other dc
 }
 public function validateEntry(entry $dbEntry)
 {
     parent::validateEntry($dbEntry);
     $dc = $this->getDc();
     if ($dc == kDataCenterMgr::getCurrentDcId()) {
         return;
     }
     $remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($dc);
     if ($remoteDCHost) {
         kFile::dumpApiRequest($remoteDCHost);
     }
     throw new KalturaAPIException(KalturaErrors::REMOTE_DC_NOT_FOUND, $dc);
 }
예제 #24
0
 public function getExternalUrl($format = StorageProfile::PLAY_FORMAT_HTTP)
 {
     $storage = StorageProfilePeer::retrieveByPK($this->getDc());
     if (!$storage || $storage->getProtocol() == StorageProfile::STORAGE_KALTURA_DC) {
         return kDataCenterMgr::getInternalRemoteUrl($this);
     }
     $urlManager = kUrlManager::getUrlManagerByStorageProfile($this->getDc());
     $url = $urlManager->getFileSyncUrl($this);
     if ($format == StorageProfile::PLAY_FORMAT_RTMP) {
         return $storage->getDeliveryRmpBaseUrl() . '/' . $url;
     }
     return $storage->getDeliveryHttpBaseUrl() . '/' . $url;
 }
 public function validateForUsage($sourceObject, $propertiesToSkip = array())
 {
     parent::validateForUsage($sourceObject, $propertiesToSkip);
     $dc = $this->getDc();
     if ($dc == kDataCenterMgr::getCurrentDcId()) {
         return;
     }
     $remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($dc);
     if ($remoteDCHost) {
         kFileUtils::dumpApiRequest($remoteDCHost);
     }
     throw new KalturaAPIException(KalturaErrors::REMOTE_DC_NOT_FOUND, $dc);
 }
예제 #26
0
 /**
  * Update media server status
  * 
  * @action reportStatus
  * @param string $hostname
  * @param KalturaMediaServerStatus $mediaServerStatus
  * @return KalturaMediaServer
  */
 function reportStatusAction($hostname, KalturaMediaServerStatus $mediaServerStatus)
 {
     $dbMediaServer = MediaServerPeer::retrieveByHostname($hostname);
     if (!$dbMediaServer) {
         $dbMediaServer = new MediaServer();
         $dbMediaServer->setHostname($hostname);
         $dbMediaServer->setDc(kDataCenterMgr::getCurrentDcId());
     }
     $mediaServerStatus->toUpdatableObject($dbMediaServer);
     $dbMediaServer->save();
     $mediaServer = new KalturaMediaServer();
     $mediaServer->fromObject($dbMediaServer, $this->getResponseProfile());
     return $mediaServer;
 }
예제 #27
0
 /**
  * generate unique string id for annotation
  */
 public function getUniqueAnnotationId()
 {
     $dc = kDataCenterMgr::getCurrentDc();
     for ($i = 0; $i < 10; $i++) {
         $id = $dc["id"] . '_' . kString::generateStringId();
         $existingObject = AnnotationPeer::retrieveByPK($id);
         if ($existingObject) {
             KalturaLog::log(__METHOD__ . ": id [{$id}] already exists");
         } else {
             return $id;
         }
     }
     throw new Exception("Could not find unique id for annotation");
 }
예제 #28
0
 /**
  * generate unique string id for CuePoint
  */
 private function calculateId()
 {
     $currentDcId = kDataCenterMgr::getCurrentDcId();
     for ($i = 0; $i < 10; $i++) {
         $id = $currentDcId . '_' . kString::generateStringId();
         $existingObject = CuePointPeer::retrieveByPKNoFilter($id);
         if ($existingObject) {
             KalturaLog::log(__METHOD__ . ": id [{$id}] already exists");
         } else {
             return $id;
         }
     }
     throw new Exception("Could not find unique id for CuePoint");
 }
예제 #29
0
 private function calculateId()
 {
     $dc = kDataCenterMgr::getCurrentDc();
     for ($i = 0; $i < 10; $i++) {
         $id = $dc["id"] . '_' . kString::generateStringId();
         $existingObject = AppTokenPeer::retrieveByPkNoFilter($id);
         if ($existingObject) {
             KalturaLog::log("ID [{$id}] already exists");
         } else {
             return $id;
         }
     }
     throw new Exception("Could not find unique id for AppToken");
 }
예제 #30
0
 public function setEntryBroadcastingUrls(LiveStreamEntry $dbEntry)
 {
     $currentDc = kDataCenterMgr::getCurrentDcId();
     $hostname = $this->getHostname($currentDc, $dbEntry->getSource());
     $dbEntry->setPrimaryBroadcastingUrl($this->getBroadcastUrl($dbEntry, kBroadcastUrlManager::PROTOCOL_RTMP, $hostname, kBroadcastUrlManager::PRIMARY_MEDIA_SERVER_INDEX));
     $dbEntry->setPrimaryRtspBroadcastingUrl($this->getBroadcastUrl($dbEntry, kBroadcastUrlManager::PROTOCOL_RTSP, $hostname, kBroadcastUrlManager::PRIMARY_MEDIA_SERVER_INDEX, true));
     $configuration = $this->getConfiguration();
     foreach ($configuration as $dc => $config) {
         if (!is_numeric($dc) || $dc == $currentDc) {
             continue;
         }
         $hostname = $this->getHostname($dc, $dbEntry->getSource());
         $dbEntry->setSecondaryBroadcastingUrl($this->getBroadcastUrl($dbEntry, kBroadcastUrlManager::PROTOCOL_RTMP, $hostname, kBroadcastUrlManager::SECONDARY_MEDIA_SERVER_INDEX));
         $dbEntry->setSecondaryRtspBroadcastingUrl($this->getBroadcastUrl($dbEntry, kBroadcastUrlManager::PROTOCOL_RTSP, $hostname, kBroadcastUrlManager::SECONDARY_MEDIA_SERVER_INDEX, true));
     }
 }