/**
  * Mark a job execution as failed
  * @param JobExecution $jobExecution
  */
 public function markAsFailed(JobExecution $jobExecution)
 {
     $jobExecution->setStatus(new BatchStatus(BatchStatus::FAILED));
     $jobExecution->setExitStatus(new ExitStatus(ExitStatus::FAILED));
     $jobExecution->setEndTime(new \DateTime('now'));
     $jobExecution->addFailureException(new \Exception('An exception occured during the job execution'));
     $this->entityManager->persist($jobExecution);
     $this->entityManager->flush();
 }
Esempio n. 2
0
 public function testExecuteStoppingWithNoStep()
 {
     $jobInstance = new JobInstance('test_connector', JobInstance::TYPE_IMPORT, 'test_job_instance');
     $jobExecution = new JobExecution($jobInstance);
     $jobExecution->setStatus(new BatchStatus(BatchStatus::STOPPING));
     $this->job->setJobRepository($this->jobRepository);
     $this->job->execute($jobExecution);
     $this->assertNull($jobExecution->getStartTime());
     $this->assertEquals(BatchStatus::STOPPED, $jobExecution->getStatus()->getValue(), 'Batch status stopped');
     $this->assertEquals(ExitStatus::NOOP, $jobExecution->getExitStatus()->getExitCode(), 'Exit status completed');
 }
Esempio n. 3
0
 public function loadJobExecutions(ObjectManager $manager)
 {
     $handle = fopen(__DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'job_execution_data.csv', 'r');
     $headers = fgetcsv($handle, 1000, ',');
     while (($data = fgetcsv($handle, 1000, ',')) !== false) {
         $combined = array_combine($headers, $data);
         $createTime = new \DateTime('now', new \DateTimeZone('UTC'));
         $createTime->sub(\DateInterval::createFromDateString($combined['Create Time']));
         $jobExecutionEntity = new JobExecution();
         $jobExecutionEntity->setJobInstance($this->jobInstances[$combined['Job Instance']]);
         $jobExecutionEntity->setCreateTime($createTime);
         $jobExecutionEntity->setStatus(new BatchStatus($combined['Status']));
         $jobExecutionEntity->setPid($combined['Pid']);
         $manager->persist($jobExecutionEntity);
     }
     fclose($handle);
 }
Esempio n. 4
0
 /**
  * Default mapping from throwable to {@link ExitStatus}. Clients can modify the exit code using a
  * {@link StepExecutionListener}.
  *
  * @param JobExecution $jobExecution Execution of the job
  * @param string       $status       Status of the execution
  *
  * @return an {@link ExitStatus}
  */
 private function updateStatus(JobExecution $jobExecution, $status)
 {
     $jobExecution->setStatus(new BatchStatus($status));
 }
 /**
  * {@inheritDoc}
  */
 public function setStatus(\Akeneo\Bundle\BatchBundle\Job\BatchStatus $status)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setStatus', array($status));
     return parent::setStatus($status);
 }