예제 #1
0
 /**
  * @param QueryRequest $queryRequest
  * @return mixed
  * @throws OverlappingException
  * @throws WriteReadException
  */
 public function updateSnapshot(QueryRequest $queryRequest)
 {
     // Mode 0 is the live mode
     $strategyFactory = new StrategyFactory();
     $strategyFactory->setQueryValidator($this->queryValidator);
     $strategy = $strategyFactory->createStrategy(SnapshotService::LIVE_MODE);
     $results = $strategy->getResults($queryRequest);
     $duration = $strategy->getDuration();
     $this->snapshotManager->init();
     $this->snapshotManager->setQueryRequest($queryRequest);
     try {
         $this->snapshotManager->writeSnapshot($results);
     } catch (WriteReadException $e) {
         throw $e;
     } catch (IOException $e) {
         throw $e;
     }
     return $duration;
 }
예제 #2
0
 /**
  * @param $mode
  * @return bool
  * @throws TypeNotValidException
  */
 public static function validateMode($mode)
 {
     $exists = array_key_exists($mode, StrategyFactory::getModes());
     if (!$exists) {
         $description = ExceptionMessage::TYPE_NOT_VALID("the mode given ({$mode}) was not valid");
         throw new TypeNotValidException($description, 500);
     }
     return true;
 }