IN PROGRESS - BATCH-858: Pause / resume of Job
pausing should now work
This commit is contained in:
@@ -232,16 +232,27 @@ public abstract class AbstractJob implements Job, BeanNameAware, InitializingBea
|
||||
|
||||
// The job was already stopped before we even got this far. Deal
|
||||
// with it in the same way as any other interruption.
|
||||
execution.setStatus(BatchStatus.STOPPED);
|
||||
execution.setExitStatus(ExitStatus.FINISHED);
|
||||
if (execution.getStatus() == BatchStatus.PAUSED) {
|
||||
// do nothing
|
||||
}
|
||||
else {
|
||||
|
||||
execution.setStatus(BatchStatus.STOPPED);
|
||||
execution.setExitStatus(ExitStatus.FINISHED);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (JobInterruptedException e) {
|
||||
logger.error(e);
|
||||
execution.setExitStatus(ExitStatus.FAILED);
|
||||
execution.setStatus(BatchStatus.STOPPED);
|
||||
execution.addFailureException(e);
|
||||
if (execution.getStatus() == BatchStatus.PAUSED) {
|
||||
// do nothing
|
||||
}
|
||||
else {
|
||||
execution.setExitStatus(ExitStatus.FAILED);
|
||||
execution.setStatus(BatchStatus.STOPPED);
|
||||
execution.addFailureException(e);
|
||||
}
|
||||
}
|
||||
catch (Throwable t) {
|
||||
logger.error(t);
|
||||
|
||||
@@ -87,6 +87,8 @@ public class SimpleJobLauncher implements JobLauncher, InitializingBean {
|
||||
if (lastExecution != null) {
|
||||
if (lastExecution.getStatus() == BatchStatus.PAUSED) {
|
||||
jobExecution = lastExecution;
|
||||
// this execution will be continued => delete the end time
|
||||
jobExecution.setEndTime(null);
|
||||
}
|
||||
else if (!job.isRestartable()) {
|
||||
throw new JobRestartException("JobInstance already exists and is not restartable");
|
||||
|
||||
@@ -320,8 +320,9 @@ public class SimpleJobRepository implements JobRepository {
|
||||
* @param stepExecution
|
||||
*/
|
||||
private void checkForInterruption(StepExecution stepExecution){
|
||||
jobExecutionDao.synchronizeStatus(stepExecution.getJobExecution());
|
||||
if(stepExecution.getJobExecution().getStatus() == BatchStatus.STOPPING){
|
||||
JobExecution jobExecution = stepExecution.getJobExecution();
|
||||
jobExecutionDao.synchronizeStatus(jobExecution);
|
||||
if(jobExecution.getStatus() == BatchStatus.STOPPING || jobExecution.getStatus() == BatchStatus.PAUSED){
|
||||
stepExecution.setTerminateOnly();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user