Exemplo n.º 1
0
 /**
  * Set data to JobResult
  * TODO: Find a way to work with multiple amount of job and step executions
  * TODO https://magecore.atlassian.net/browse/BAP-2600
  *
  * @param JobResult $jobResult
  * @param JobInstance $jobInstance
  */
 protected function setJobResultData(JobResult $jobResult, JobInstance $jobInstance)
 {
     $jobResult->setJobId($jobInstance->getId());
     $jobResult->setJobCode($jobInstance->getCode());
     /** @var JobExecution $jobExecution */
     $jobExecution = $jobInstance->getJobExecutions()->first();
     if ($jobExecution) {
         $stepExecutions = $jobExecution->getStepExecutions();
         /** @var StepExecution $firstStepExecution */
         $firstStepExecution = $stepExecutions->first();
         if ($firstStepExecution) {
             $context = $this->contextRegistry->getByStepExecution($firstStepExecution);
             if ($stepExecutions->count() > 1) {
                 /** @var StepExecution $stepExecution */
                 foreach ($stepExecutions->slice(1) as $stepExecution) {
                     ContextHelper::mergeContextCounters($context, $this->contextRegistry->getByStepExecution($stepExecution));
                 }
             }
             $jobResult->setContext($context);
         }
     }
 }
Exemplo n.º 2
0
 protected function runPostProcessingJobs()
 {
     foreach ($this->postProcessingJobs as $jobData) {
         $jobResult = $this->executePostProcessingJob($jobData[self::JOB_TYPE_KEY], $jobData[self::JOB_NAME_KEY]);
         $jobResultContext = $jobResult->getContext();
         if ($jobResultContext instanceof ContextInterface) {
             ContextHelper::mergeContextCounters($this->stepExecutionContext, $jobResultContext);
         }
         if (!$jobResult->isSuccessful()) {
             throw new RuntimeException(sprintf('Post processing job "%s" failed. Job id "%s". Errors: %s', $jobResult->getJobCode(), $jobResult->getJobId(), implode(PHP_EOL, $jobResult->getFailureExceptions())));
         }
     }
     $this->cleanupContext();
 }