/** * 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(); // 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::fromControlPanelCommandArray($commandsList); // 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::fromSchedulerConfigArray($configList); // 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; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(SchedulerConfigPeer::DATABASE_NAME); $criteria->add(SchedulerConfigPeer::ID, $pks, Criteria::IN); $objs = SchedulerConfigPeer::doSelect($criteria, $con); } return $objs; }