Exemple #1
0
 /**
  * Runs a particular job
  * @param ESJob $job
  * @return SchedulerJobStatus
  */
 public function run(ESJob $job)
 {
     $logger = $this->getLogger();
     $class = $job->getClass();
     $jobId = $job->getId();
     $logger->info("RUNNER: Running job with id {$jobId}");
     // Check if the class exists
     if (!class_exists($job->getClass())) {
         $logger->error("Runner: Class {$class} not found for job with id {$jobId}", ESJob::getArrayFromObj($job));
         return SchedulerJobStatus::getStatusObject(SchedulerJobStatus::SCHEDULERJOB_STATUS_CLASS_NOT_FOUND, "The class {$class} has not been found");
     }
     $task = new $class();
     $task->setContainer($this->container);
     $task->setJob($job);
     $task->setUp();
     $status = $task->perform(json_decode($job->getArgs(), true));
     $task->tearDown();
     $logger->info("RUNNER: Job with id {$jobId} completed", array('status' => SchedulerJobStatus::$statuses[$status->getStatus()], 'message' => $status->getMessage()));
     return $status;
 }