Ejemplo n.º 1
0
 public function doFromObject($dbData, KalturaDetachedResponseProfile $responseProfile = null)
 {
     parent::doFromObject($dbData, $responseProfile);
     $statusesArray = $dbData->getStatuses();
     if (is_array($statusesArray)) {
         $this->statuses = KalturaSchedulerStatusArray::fromValuesArray($statusesArray, $this->schedulerId, $this->schedulerConfiguredId, $this->id, $this->configuredId, $this->type);
     }
     $this->configs = KalturaSchedulerConfigArray::fromDbArray($dbData->getConfigs());
     $this->lockedJobs = KalturaBatchJobArray::fromBatchJobArray($dbData->getLockedJobs());
     return $this;
 }
 public function fromObject($dbData)
 {
     parent::fromObject($dbData);
     $statusesArray = $dbData->getStatuses();
     if (is_array($statusesArray)) {
         $this->statuses = KalturaSchedulerStatusArray::fromValuesArray($statusesArray, $this->schedulerId, $this->schedulerConfiguredId, $this->id, $this->configuredId, $this->type);
     }
     $this->configs = KalturaSchedulerConfigArray::fromSchedulerConfigArray($dbData->getConfigs());
     $this->lockedJobs = KalturaBatchJobArray::fromBatchJobArray($dbData->getLockedJobs());
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * batch reportStatus action saves the a status attribute from a remote scheduler and returns pending commands for the scheduler
  * 
  * @action reportStatus
  * @param KalturaScheduler $scheduler The scheduler
  * @param KalturaSchedulerStatusArray $schedulerStatuses A scheduler status array
  * @param KalturaWorkerQueueFilterArray $workerQueueFilters Filters list to get queues
  * @return KalturaSchedulerStatusResponse
  */
 function reportStatusAction(KalturaScheduler $scheduler, KalturaSchedulerStatusArray $schedulerStatuses, KalturaWorkerQueueFilterArray $workerQueueFilters)
 {
     $schedulerDb = $this->getOrCreateScheduler($scheduler);
     $schedulerChanged = false;
     // saves the statuses to the DB
     foreach ($schedulerStatuses as $schedulerStatus) {
         $schedulerStatus->schedulerId = $schedulerDb->getId();
         $schedulerStatus->schedulerConfiguredId = $scheduler->configuredId;
         if ($schedulerStatus->workerConfiguredId) {
             $worker = $this->getOrCreateWorker($schedulerDb, $schedulerStatus->workerConfiguredId, $schedulerStatus->workerType);
             $worker->setStatus($schedulerStatus->type, $schedulerStatus->value);
             $worker->save();
             $schedulerStatus->workerId = $worker->getId();
         } else {
             $schedulerChanged = true;
             $schedulerDb->setStatus($schedulerStatus->type, $schedulerStatus->value);
         }
         $schedulerStatusDb = new SchedulerStatus();
         $schedulerStatus->toObject($schedulerStatusDb);
         $schedulerStatusDb->save();
     }
     if ($schedulerChanged) {
         $schedulerDb->save();
     }
     // creates a response
     $schedulerStatusResponse = new KalturaSchedulerStatusResponse();
     if (kConf::hasParam('batch_enable_control_panel') && kConf::get('batch_enable_control_panel')) {
         // gets the control pannel commands
         $c = new Criteria();
         $c->add(ControlPanelCommandPeer::SCHEDULER_ID, $schedulerDb->getId());
         $c->add(ControlPanelCommandPeer::TYPE, KalturaControlPanelCommandType::CONFIG, Criteria::NOT_EQUAL);
         $c->add(ControlPanelCommandPeer::STATUS, KalturaControlPanelCommandStatus::PENDING);
         $commandsList = ControlPanelCommandPeer::doSelect($c);
         foreach ($commandsList as $command) {
             $command->setStatus(KalturaControlPanelCommandStatus::HANDLED);
             $command->save();
         }
         $schedulerStatusResponse->controlPanelCommands = KalturaControlPanelCommandArray::fromDbArray($commandsList, $this->getResponseProfile());
         // gets new configs
         $c = new Criteria();
         $c->add(SchedulerConfigPeer::SCHEDULER_ID, $schedulerDb->getId());
         $c->add(SchedulerConfigPeer::COMMAND_STATUS, KalturaControlPanelCommandStatus::PENDING);
         $configList = SchedulerConfigPeer::doSelect($c);
         foreach ($configList as $config) {
             $config->setCommandStatus(KalturaControlPanelCommandStatus::HANDLED);
             $config->save();
         }
         $schedulerStatusResponse->schedulerConfigs = KalturaSchedulerConfigArray::fromDbArray($configList, $this->getResponseProfile());
     } else {
         $schedulerStatusResponse->controlPanelCommands = new KalturaControlPanelCommandArray();
         $schedulerStatusResponse->schedulerConfigs = new KalturaSchedulerConfigArray();
     }
     // gets queues length
     $schedulerStatusResponse->queuesStatus = new KalturaBatchQueuesStatusArray();
     foreach ($workerQueueFilters as $workerQueueFilter) {
         $dbJobType = kPluginableEnumsManager::apiToCore('BatchJobType', $workerQueueFilter->jobType);
         $filter = $workerQueueFilter->filter->toFilter($dbJobType);
         $batchQueuesStatus = new KalturaBatchQueuesStatus();
         $batchQueuesStatus->jobType = $workerQueueFilter->jobType;
         $batchQueuesStatus->workerId = $workerQueueFilter->workerId;
         $batchQueuesStatus->size = kBatchManager::getQueueSize($workerQueueFilter->schedulerId, $workerQueueFilter->workerId, $dbJobType, $filter);
         $schedulerStatusResponse->queuesStatus[] = $batchQueuesStatus;
     }
     return $schedulerStatusResponse;
 }
Ejemplo n.º 4
0
 /**
  * @param Scheduler $dbData
  * @return KalturaScheduler
  */
 public function statusFromObject($dbData)
 {
     $this->fromObject($dbData);
     $this->workers = KalturaSchedulerWorkerArray::statusFromSchedulerWorkerArray($dbData->getWorkers());
     $this->configs = KalturaSchedulerConfigArray::fromDbArray($dbData->getConfigs());
     return $this;
 }
 /**
  * @param SchedulerWorker $dbData
  * @return KalturaScheduler
  */
 public function statusFromObject($dbData)
 {
     $this->fromObject($dbData);
     $this->configs = KalturaSchedulerConfigArray::fromSchedulerConfigArray($dbData->getConfigs());
     $this->lockedJobs = KalturaBatchJobArray::fromBatchJobArray($dbData->getLockedJobs());
     $this->avgWait = BatchJobPeer::doAvgTimeDiff($this->type, BatchJobPeer::CREATED_AT, BatchJobPeer::QUEUE_TIME, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
     $this->avgWork = BatchJobPeer::doAvgTimeDiff($this->type, BatchJobPeer::QUEUE_TIME, BatchJobPeer::FINISH_TIME, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
     return $this;
 }