@Override public void execute(StepExecution stepExecution) throws JobInterruptedException { throw new JobInterruptedException("Stopped"); } }), "end0"));
@Override public void execute(StepExecution stepExecution) throws JobInterruptedException { throw new JobInterruptedException("Stopped"); } }), "end0"));
@Override public void checkInterrupted(StepExecution stepExecution) throws JobInterruptedException { throw new JobInterruptedException("interrupted"); } };
@Override public void execute(StepExecution stepExecution) throws JobInterruptedException { throw new JobInterruptedException("Stopped"); } }), "end0"));
@Override public void execute(StepExecution stepExecution) throws JobInterruptedException { throw new JobInterruptedException("Stopped"); } }), "end0"));
/** * Returns if the current job lifecycle has been interrupted by checking if * the current thread is interrupted. */ @Override public void checkInterrupted(StepExecution stepExecution) throws JobInterruptedException { if (isInterrupted(stepExecution)) { throw new JobInterruptedException("Job interrupted status detected."); } }
@Override public Exception getException(String msg) throws Exception { return new JobInterruptedException(msg); }
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { contribution.setExitStatus(new ExitStatus("FUNNY")); throw new JobInterruptedException("Planned"); } });
throw new JobInterruptedException("Job interrupted while executing system command '" + command + "'");
@Override public String executeStep(Step step) throws JobInterruptedException, JobRestartException, StartLimitExceededException { boolean isRerun = isStepRestart(step); StepExecution stepExecution = stepHandler.handleStep(step, execution); stepExecutionHolder.set(stepExecution); if (stepExecution == null) { return ExitStatus.COMPLETED.getExitCode(); } if (stepExecution.isTerminateOnly()) { throw new JobInterruptedException("Step requested termination: "+stepExecution, stepExecution.getStatus()); } if(isRerun) { stepExecution.getExecutionContext().put("batch.restart", true); } return stepExecution.getExitStatus().getExitCode(); }
@Test public void testInterruptedAfterUnknownStatus() throws Exception { step1.setStartLimit(5); step2.setStartLimit(5); final JobInterruptedException exception = new JobInterruptedException("Interrupt!", BatchStatus.UNKNOWN); step1.setProcessException(exception); job.execute(jobExecution); assertEquals(1, jobExecution.getAllFailureExceptions().size()); assertEquals(exception, jobExecution.getStepExecutions().iterator().next().getFailureExceptions().get(0)); assertEquals(0, list.size()); checkRepository(BatchStatus.UNKNOWN, ExitStatus.STOPPED); }
@Test public void testInterrupted() throws Exception { step1.setStartLimit(5); step2.setStartLimit(5); final JobInterruptedException exception = new JobInterruptedException("Interrupt!"); step1.setProcessException(exception); job.execute(jobExecution); assertEquals(1, jobExecution.getAllFailureExceptions().size()); assertEquals(exception, jobExecution.getStepExecutions().iterator().next().getFailureExceptions().get(0)); assertEquals(0, list.size()); checkRepository(BatchStatus.STOPPED, ExitStatus.STOPPED); }
@Test public void testInterruptWithListener() throws Exception { step1.setProcessException(new JobInterruptedException("job interrupted!")); JobExecutionListener listener = mock(JobExecutionListener.class); listener.beforeJob(jobExecution); listener.afterJob(jobExecution); job.setJobExecutionListeners(new JobExecutionListener[] { listener }); job.execute(jobExecution); assertEquals(BatchStatus.STOPPED, jobExecution.getStatus()); }
throw new JobInterruptedException("JobExecution interrupted.");
JobRestartException, StartLimitExceededException { if (execution.isStopping()) { throw new JobInterruptedException("JobExecution interrupted."); throw new JobInterruptedException("Job interrupted by step execution");
@Test public void testInterruptedWithCustomStatus() throws Exception { taskletStep.setTasklet(new Tasklet() { @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { contribution.setExitStatus(new ExitStatus("FUNNY")); throw new JobInterruptedException("Planned"); } }); taskletStep.execute(stepExecution); assertEquals(STOPPED, stepExecution.getStatus()); assertEquals("FUNNY", stepExecution.getExitStatus().getExitCode()); }
if (currentStepExecution.getStatus() == BatchStatus.STOPPING || currentStepExecution.getStatus() == BatchStatus.STOPPED) { // Ensure that the job gets the message that it is stopping execution.setStatus(BatchStatus.STOPPING); throw new JobInterruptedException("Job interrupted by step execution"); }
/** * Returns if the current job lifecycle has been interrupted by checking if * the current thread is interrupted. */ @Override public void checkInterrupted(StepExecution stepExecution) throws JobInterruptedException { if (isInterrupted(stepExecution)) { throw new JobInterruptedException("Job interrupted status detected."); } }
/** * Returns if the current job lifecycle has been interrupted by checking if * the current thread is interrupted. */ @Override public void checkInterrupted(StepExecution stepExecution) throws JobInterruptedException { if (isInterrupted(stepExecution)) { throw new JobInterruptedException("Job interrupted status detected."); } }
/** * Returns if the current job lifecycle has been interrupted by checking if * the current thread is interrupted. */ @Override public void checkInterrupted(StepExecution stepExecution) throws JobInterruptedException { if (isInterrupted(stepExecution)) { throw new JobInterruptedException("Job interrupted status detected."); } }