Exemple #1
0
 public static function get()
 {
     if (self::$_uniqueId === null) {
         self::$_uniqueId = (string) rand();
         if (php_sapi_name() !== 'cli') {
             header('X-Kaltura-Session:' . self::$_uniqueId, false);
         }
     }
     return self::$_uniqueId;
 }
 protected static function set($key, array $value = array())
 {
     $value[self::CACHE_VALUE_HOSTNAME] = infraRequestUtils::getHostname();
     $value[self::CACHE_VALUE_TIME] = time();
     $value[self::CACHE_VALUE_SESSION] = UniqueId::get();
     $value[self::CACHE_VALUE_VERSION] = self::getCacheVersion();
     $key = self::addCacheVersion($key);
     KalturaLog::debug("Key [{$key}]");
     $cacheStores = self::getStores();
     foreach ($cacheStores as $cacheStore) {
         /* @var $cacheStore kBaseCacheWrapper */
         $cacheStore->set($key, $value);
     }
 }
Exemple #3
0
 /**
  * @param KSchedularTaskConfig $taskConfig
  */
 public function __construct($taskConfig = null)
 {
     /*
      *  argv[0] - the script name
      *  argv[1] - serialized KSchedulerConfig config
      */
     global $argv, $g_context;
     $this->sessionKey = uniqid('sess');
     $this->start = microtime(true);
     if (is_null($taskConfig)) {
         $data = gzuncompress(base64_decode($argv[1]));
         self::$taskConfig = unserialize($data);
     } else {
         self::$taskConfig = $taskConfig;
     }
     if (!self::$taskConfig) {
         die("Task config not supplied");
     }
     date_default_timezone_set(self::$taskConfig->getTimezone());
     // clear seperator between executions
     KalturaLog::debug('___________________________________________________________________________________');
     KalturaLog::stderr('___________________________________________________________________________________', KalturaLog::DEBUG);
     KalturaLog::info(file_get_contents(dirname(__FILE__) . "/../VERSION.txt"));
     if (!self::$taskConfig instanceof KSchedularTaskConfig) {
         KalturaLog::err('config is not a KSchedularTaskConfig');
         die;
     }
     KalturaLog::debug("set_time_limit({" . self::$taskConfig->maximumExecutionTime . "})");
     set_time_limit(self::$taskConfig->maximumExecutionTime);
     KalturaLog::info('Batch index [' . $this->getIndex() . '] session key [' . $this->sessionKey . ']');
     self::$kClientConfig = new KalturaConfiguration();
     self::$kClientConfig->setLogger($this);
     self::$kClientConfig->serviceUrl = self::$taskConfig->getServiceUrl();
     self::$kClientConfig->curlTimeout = self::$taskConfig->getCurlTimeout();
     if (isset(self::$taskConfig->clientConfig)) {
         foreach (self::$taskConfig->clientConfig as $attr => $value) {
             self::$kClientConfig->{$attr} = $value;
         }
     }
     self::$kClient = new KalturaClient(self::$kClientConfig);
     self::$kClient->setPartnerId(self::$taskConfig->getPartnerId());
     self::$clientTag = 'batch: ' . self::$taskConfig->getSchedulerName() . ' ' . get_class($this) . " index: {$this->getIndex()} sessionId: " . UniqueId::get();
     self::$kClient->setClientTag(self::$clientTag);
     //$ks = self::$kClient->session->start($secret, "user-2", KalturaSessionType::ADMIN);
     $ks = $this->createKS();
     self::$kClient->setKs($ks);
     KDwhClient::setEnabled(self::$taskConfig->getDwhEnabled());
     KDwhClient::setFileName(self::$taskConfig->getDwhPath());
     $this->onBatchUp();
     KScheduleHelperManager::saveRunningBatch($this->getName(), $this->getIndex());
 }
Exemple #4
0
 public function __toString()
 {
     if (self::$_uniqueId === null) {
         self::$_uniqueId = (string) rand();
         // add a the unique id to Apache's internal variable so we can later log it using the %{KalturaLog_UniqueId}n placeholder
         // within the LogFormat apache directive. This way each access_log record can be matched with its kaltura log lines.
         // before setting the apache note name and value, a condition checks if function exists,
         // due to fact that running from command line will not define this function
         if (function_exists('apache_note')) {
             apache_note("KalturaLog_UniqueId", self::$_uniqueId);
         }
     }
     return self::$_uniqueId;
 }
 public static function initApiMonitor($cached, $action, $partnerId, $clientTag = null)
 {
     if (is_null(self::$stream)) {
         self::init();
     }
     if (!self::$stream) {
         return;
     }
     self::$apiStartTime = microtime(true);
     self::$basicEventInfo = array(self::FIELD_SERVER => infraRequestUtils::getHostname(), self::FIELD_IP_ADDRESS => infraRequestUtils::getRemoteAddress(), self::FIELD_PARTNER_ID => $partnerId, self::FIELD_ACTION => $action, self::FIELD_CLIENT_TAG => $clientTag);
     if (!$cached) {
         require_once __DIR__ . '/../../../../../infra/log/UniqueId.php';
         self::$basicEventInfo[self::FIELD_UNIQUE_ID] = UniqueId::get();
     }
 }