コード例 #1
0
ファイル: KDwhClient.class.php プロジェクト: DBezemer/server
 public static function getInstance()
 {
     if (is_null(self::$s_dwh_client)) {
         self::$s_dwh_client = new KDwhClient(self::$s_file_name);
     }
     return self::$s_dwh_client;
 }
コード例 #2
0
ファイル: KBatchKiller.php プロジェクト: DBezemer/server
 protected function logToDWH($event_id, $filePath = null, $idleTime = null)
 {
     $event = new KBatchEvent();
     $event->value_1 = $idleTime;
     $event->value_2 = $filePath;
     $event->batch_client_version = "1.0";
     $event->batch_event_time = time();
     $event->batch_event_type_id = $event_id;
     $event->batch_session_id = $this->config->sessionKey;
     $event->batch_id = $this->config->batchIndex;
     $event->batch_name = $this->config->batchName;
     $event->section_id = $this->config->workerId;
     $event->batch_type = $this->config->workerType;
     $event->location_id = $this->config->schedulerId;
     $event->host_name = $this->config->schedulerName;
     KDwhClient::send($event);
 }
コード例 #3
0
 protected function onEvent(KBatchEvent $event, KSchedularTaskConfig $taskConfig)
 {
     $event->batch_client_version = "1.0";
     $event->batch_event_time = time();
     $event->batch_name = $taskConfig->name;
     $event->section_id = $taskConfig->id;
     $event->batch_type = $taskConfig->type;
     $event->location_id = $this->schedulerConfig->getId();
     $event->host_name = $this->schedulerConfig->getName();
     KDwhClient::send($event);
 }
コード例 #4
0
ファイル: KBatchBase.class.php プロジェクト: DBezemer/server
 /**
  * @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());
 }
コード例 #5
0
ファイル: KBatchBase.class.php プロジェクト: richhl/kalturaCE
 /**
  * @param KSchedularTaskConfig $taskConfig
  */
 public function __construct($taskConfig = null)
 {
     parent::__construct($taskConfig);
     KalturaLog::debug('This batch index: ' . $this->getIndex());
     KalturaLog::debug('This session key: ' . $this->sessionKey);
     $this->kClientConfig = new KalturaConfiguration();
     $this->kClientConfig->setLogger($this);
     $this->kClientConfig->serviceUrl = $this->taskConfig->getServiceUrl();
     $this->kClientConfig->curlTimeout = $this->taskConfig->getCurlTimeout();
     $this->kClientConfig->clientTag = 'batch: ' . $this->taskConfig->getSchedulerName();
     $this->kClient = new KalturaClient($this->kClientConfig);
     //$ks = $this->kClient->session->start($secret, "user-2", KalturaSessionType::ADMIN);
     $ks = $this->createKS();
     $this->kClient->setKs($ks);
     KDwhClient::setFileName($this->taskConfig->getDwhPath());
     $this->onBatchUp();
     KScheduleHelperManager::saveRunningBatch($this->taskConfig->getCommandsDir(), $this->getName(), $this->getIndex());
 }
コード例 #6
0
ファイル: test1.php プロジェクト: DBezemer/server
/**
 * 
 * @package Scheduler
 * @subpackage Debug
 */
require_once dirname(__FILE__) . "/../KDwhClient.class.php";
require_once dirname(__FILE__) . "/../KBatchEvent.class.php";
KDwhClient::setFileName("/var/log/dwh/dwh_batch_events");
$param = $argv[1];
$loop_size = $argv[2];
$session_id = null;
for ($i = 0; $i < $loop_size; $i++) {
    if ($i % 10 == 0) {
        $session_id = md5("abc" . time());
    }
    $event = new KBatchEvent();
    $event->batch_client_version = "123|{$param}";
    $event->batch_event_time = time();
    $event->batch_event_type_id = rand(1, 10);
    $event->batch_name = "import";
    $event->batch_id = $i % 8;
    $event->batch_session_id = $session_id;
    $event->entry_id = rand(1000, 10000);
    $event->host_name = "host {$param}";
    $event->location_id = "1";
    $event->partner_id = rand(1, 10);
    $event->section_id = "1";
    KDwhClient::send($event);
    usleep(200);
}
 /**
  * @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)) {
         $this->taskConfig = unserialize(base64_decode($argv[1]));
     } else {
         $this->taskConfig = $taskConfig;
     }
     if (!$this->taskConfig) {
         die("Task config not supplied");
     }
     date_default_timezone_set($this->taskConfig->getTimezone());
     // clear seperator between executions
     KalturaLog::debug('___________________________________________________________________________________');
     KalturaLog::info(file_get_contents(dirname(__FILE__) . "/../VERSION.txt"));
     if (!$this->taskConfig instanceof KSchedularTaskConfig) {
         KalturaLog::err('config is not a KSchedularTaskConfig');
         die;
     }
     KalturaLog::debug("set_time_limit({$this->taskConfig->maximumExecutionTime})");
     set_time_limit($this->taskConfig->maximumExecutionTime);
     KalturaLog::debug('This batch index: ' . $this->getIndex());
     KalturaLog::debug('This session key: ' . $this->sessionKey);
     $this->kClientConfig = new KalturaConfiguration($this->taskConfig->getPartnerId());
     $this->kClientConfig->setLogger($this);
     $this->kClientConfig->serviceUrl = $this->taskConfig->getServiceUrl();
     $this->kClientConfig->curlTimeout = $this->taskConfig->getCurlTimeout();
     $this->kClientConfig->clientTag = 'batch: ' . $this->taskConfig->getSchedulerName();
     $this->kClient = new KalturaClient($this->kClientConfig);
     //$ks = $this->kClient->session->start($secret, "user-2", KalturaSessionType::ADMIN);
     $ks = $this->createKS();
     $this->kClient->setKs($ks);
     KDwhClient::setEnabled($this->taskConfig->getDwhEnabled());
     KDwhClient::setFileName($this->taskConfig->getDwhPath());
     $this->onBatchUp();
     KScheduleHelperManager::saveRunningBatch($this->taskConfig->getCommandsDir(), $this->getName(), $this->getIndex());
 }