/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param SchedulerConfig $value A SchedulerConfig object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(SchedulerConfig $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * batch sets a configuration parameter to be loaded by a worker * * @action setWorkerConfig * @param int $workerId The id of the job to be configured * @param int $adminId The id of the admin that called the setConfig * @param string $configParam The parameter to be set * @param string $configValue The value to be set * @param string $configParamPart The parameter part to be set - for additional params * @param string $cause The reason it was changed * @return KalturaControlPanelCommand */ function setWorkerConfigAction($workerId, $adminId, $configParam, $configValue, $configParamPart = null, $cause = null) { $adminDb = kuserPeer::retrieveByPK($adminId); $workerDb = SchedulerWorkerPeer::retrieveByPK($workerId); if (!$workerDb) { throw new KalturaAPIException(KalturaErrors::WORKER_NOT_FOUND, $workerId); } $workerName = $workerDb->getName(); $schedulerId = $workerDb->getSchedulerId(); $schedulerDb = SchedulerPeer::retrieveByPK($schedulerId); if (!$schedulerDb) { throw new KalturaAPIException(KalturaErrors::SCHEDULER_NOT_FOUND, $schedulerId); } $schedulerName = $schedulerDb->getName(); $description = "Configure {$configParam} on {$schedulerName}"; if (!is_null($configParamPart)) { $description = "Configure {$configParam}.{$configParamPart} on {$schedulerName}"; } // saves the command to the DB $commandDb = new ControlPanelCommand(); $commandDb->setSchedulerId($schedulerId); $commandDb->setSchedulerConfiguredId($schedulerDb->getConfiguredId()); $commandDb->setCreatedById($adminId); $commandDb->setType(KalturaControlPanelCommandType::CONFIG); $commandDb->setStatus(KalturaControlPanelCommandStatus::PENDING); $commandDb->setDescription($description); $commandDb->setWorkerId($workerId); $commandDb->setWorkerConfiguredId($workerDb->getConfiguredId()); $commandDb->setWorkerName($workerName); $commandDb->setTargetType(KalturaControlPanelCommandTargetType::JOB); if ($adminDb) { $commandDb->setCreatedBy($adminDb->getName()); } $commandDb->setCause($cause); $commandDb->save(); // saves the new config to the DB $configDb = new SchedulerConfig(); $configDb->setSchedulerId($schedulerId); $configDb->setSchedulerConfiguredId($schedulerDb->getConfiguredId()); $configDb->setCommandId($commandDb->getId()); $configDb->setCommandStatus(KalturaControlPanelCommandStatus::PENDING); $configDb->setSchedulerName($schedulerName); $configDb->setVariable($configParam); $configDb->setVariablePart($configParamPart); $configDb->setValue($configValue); $configDb->setWorkerId($workerId); $configDb->setWorkerConfiguredId($workerDb->getConfiguredId()); $configDb->setWorkerName($workerName); if ($adminDb) { $configDb->setCreatedBy($adminDb->getName()); } $configDb->save(); $command = new KalturaControlPanelCommand(); $command->fromObject($commandDb, $this->getResponseProfile()); return $command; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param SchedulerConfig $value A SchedulerConfig object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(SchedulerConfig $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) { self::$instances[$key] = $obj; kMemoryManager::registerPeer('SchedulerConfigPeer'); } } }