Example #1
0
 /**
  * Sets status of the job to cancelled if process controller indicates to exit.
  *
  * @return boolean
  */
 public function doStop()
 {
     if ($this->controller->doStop()) {
         $this->job->setStatus(Status::CANCELLED());
         return true;
     }
     return false;
 }
 /**
  * {@inheritdoc}
  */
 public function doStop()
 {
     $time = time();
     if (null === $this->lastCheck || $this->lastCheck + $this->interval <= $time) {
         $this->lastCheck = $time;
         $this->manager->refresh($this->job);
     }
     return $this->job->getStatus() == Status::CANCELLING() || $this->job->getStatus() == Status::CANCELLED();
 }
 /**
  * @param $secondsPassed
  * @dataProvider provideSecondsLessThanInterval
  */
 public function testDoStopSkipsRefreshingIfIntervalNotExceeded($secondsPassed)
 {
     $this->manager->expects($this->exactly(1))->method('refresh')->with($this->job);
     $this->job->expects($this->any())->method('getStatus')->willReturn(Status::CANCELLING());
     $this->time->expects($this->at(0))->willReturn(0);
     $this->time->expects($this->at(1))->willReturn($secondsPassed);
     // initial invocation
     $this->subject->doStop();
     // second invocation
     $this->subject->doStop();
 }
Example #4
0
 /**
  * Copies properties of a job to another job
  *
  * @param JobInterface                             $from The job where properties are copied from
  * @param \Abc\Bundle\JobBundle\Model\JobInterface $to   The job where where properties are copied to
  * @return \Abc\Bundle\JobBundle\Model\JobInterface The copied job
  */
 public function copyJob(JobInterface $from, \Abc\Bundle\JobBundle\Model\JobInterface $to)
 {
     $to->setType($from->getType());
     $to->setResponse($from->getResponse());
     $to->setParameters($from->getParameters());
     if (null != $from->getStatus()) {
         $to->setStatus($from->getStatus());
     }
     foreach ($from->getSchedules() as $schedule) {
         $to->addSchedule($schedule);
     }
     return $to;
 }
 /**
  * @param JobInterface $job
  * @return string
  */
 private function buildFilename(JobInterface $job)
 {
     return $this->directory . DIRECTORY_SEPARATOR . $job->getTicket() . '.json';
 }