List of usage examples for org.springframework.batch.core StepExecution getStatus
public BatchStatus getStatus()
From source file:org.springframework.batch.integration.partition.JmsIntegrationTests.java
@Test public void testLaunchJob() throws Exception { int before = jobExplorer.getJobInstances(job.getName(), 0, 100).size(); assertNotNull(jobLauncher.run(job, new JobParameters())); List<JobInstance> jobInstances = jobExplorer.getJobInstances(job.getName(), 0, 100); int after = jobInstances.size(); assertEquals(1, after - before);/*from w w w . j ava 2 s. co m*/ JobExecution jobExecution = jobExplorer.getJobExecutions(jobInstances.get(jobInstances.size() - 1)).get(0); assertEquals(jobExecution.getExitStatus().getExitDescription(), BatchStatus.COMPLETED, jobExecution.getStatus()); assertEquals(3, jobExecution.getStepExecutions().size()); for (StepExecution stepExecution : jobExecution.getStepExecutions()) { // BATCH-1703: we are using a map dao so the step executions in the job execution are old and we need to // pull them back out of the repository... stepExecution = jobExplorer.getStepExecution(jobExecution.getId(), stepExecution.getId()); logger.debug("" + stepExecution); assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus()); } }
From source file:org.springframework.cloud.task.batch.partition.DeployerPartitionHandler.java
private Collection<StepExecution> pollReplies(final StepExecution masterStepExecution, final Set<StepExecution> executed, final Set<StepExecution> candidates, final int size) throws Exception { final Collection<StepExecution> result = new ArrayList<>(executed.size()); Callable<Collection<StepExecution>> callback = new Callable<Collection<StepExecution>>() { @Override/* w ww .ja va 2 s .c om*/ public Collection<StepExecution> call() throws Exception { Set<StepExecution> newExecuted = new HashSet<>(); for (StepExecution curStepExecution : executed) { if (!result.contains(curStepExecution)) { StepExecution partitionStepExecution = jobExplorer.getStepExecution( masterStepExecution.getJobExecutionId(), curStepExecution.getId()); if (isComplete(partitionStepExecution.getStatus())) { result.add(partitionStepExecution); currentWorkers--; if (!candidates.isEmpty()) { launchWorkers(candidates, newExecuted); candidates.removeAll(newExecuted); } } } } executed.addAll(newExecuted); if (result.size() == size) { return result; } else { return null; } } }; Poller<Collection<StepExecution>> poller = new DirectPoller<>(this.pollInterval); Future<Collection<StepExecution>> resultsFuture = poller.poll(callback); if (timeout >= 0) { return resultsFuture.get(timeout, TimeUnit.MILLISECONDS); } else { return resultsFuture.get(); } }
From source file:org.springframework.xd.dirt.plugins.job.support.listener.FileDeletionStepExecutionListener.java
@Override public ExitStatus afterStep(StepExecution stepExecution) { if (!deleteFiles) { return stepExecution.getExitStatus(); }/*from ww w. j a v a2 s.c o m*/ if (stepExecution.getStatus().equals(BatchStatus.STOPPED) || stepExecution.getStatus().isUnsuccessful()) { logger.warn("Job is stopped, or failed to complete successfully. File deletion will be skipped"); return stepExecution.getExitStatus(); } if (resources != null) { deleteResources(); } else { deleteFilePath(stepExecution.getJobExecution().getJobParameters() .getString(ExpandedJobParametersConverter.ABSOLUTE_FILE_PATH)); } return stepExecution.getExitStatus(); }
From source file:org.springframework.yarn.batch.container.DefaultBatchYarnContainer.java
@Override protected void runInternal() { Long jobExecutionId = safeParse(getEnvironment(YarnSystemConstants.AMSERVICE_BATCH_JOBEXECUTIONID)); Long stepExecutionId = safeParse(getEnvironment(YarnSystemConstants.AMSERVICE_BATCH_STEPEXECUTIONID)); String stepName = getEnvironment(YarnSystemConstants.AMSERVICE_BATCH_STEPNAME); if (log.isDebugEnabled()) { log.debug("Requesting StepExecution: " + jobExecutionId + " / " + stepExecutionId); }/*from w w w. ja v a 2s .co m*/ StepExecution stepExecution = getJobExplorer().getStepExecution(jobExecutionId, stepExecutionId); if (stepExecution == null) { throw new NoSuchStepException("No StepExecution could be located for this request: "); } if (log.isDebugEnabled()) { log.debug("Got StepExecution: " + stepExecution); log.debug("Locating Step: " + stepName); } Step step = getStepLocator().getStep(stepName); if (log.isDebugEnabled()) { log.debug("Located step: " + step); } if (step == null) { throw new NoSuchStepException(String.format("No Step with name [%s] could be located.", stepName)); } try { if (log.isDebugEnabled()) { log.debug("Executing step: " + step + " / " + stepExecution); } step.execute(stepExecution); } catch (JobInterruptedException e) { log.error("error executing step 1", e); stepExecution.setStatus(BatchStatus.STOPPED); } catch (Throwable e) { log.error("error executing step 2", e); stepExecution.addFailureException(e); stepExecution.setStatus(BatchStatus.FAILED); } if (log.isDebugEnabled()) { log.debug("Finished remote step run, status is " + stepExecution.getStatus()); } MindAppmasterServiceClient client = (MindAppmasterServiceClient) getIntegrationServiceClient(); PartitionedStepExecutionStatusReq req = new PartitionedStepExecutionStatusReq(); req.stepExecution = JobRepositoryRpcFactory.convertStepExecutionType(stepExecution); BaseResponseObject doMindRequest = client.doMindRequest(req); log.info("got response for status update: " + doMindRequest); }