Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide method for stopping Batch 5 Jobs upon user request #5990

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,12 @@ public JobExecution stop(Long jobExecutionId) throws NoSuchJobExecutionException
if (!jobExecution.isRunning()) {
throw new JobExecutionNotRunningException("JobExecution is not running and therefore cannot be stopped");
}

// Indicate the execution should be stopped by setting it's status to
// 'STOPPING'. It is assumed that
// the step implementation will check this status at chunk boundaries.
logger.info("Stopping job execution: " + jobExecution);

jobExecution.setStatus(BatchStatus.STOPPED);
jobExecution.setStatus(BatchStatus.STOPPING);
onobc marked this conversation as resolved.
Show resolved Hide resolved
jobRepository.update(jobExecution);
return jobExecution;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void stoppingJobExecutionShouldLeaveJobExecutionWithStatusOfStopping() throws Ex
assertThat(jobExecution.getStatus()).isNotEqualTo(BatchStatus.STOPPING);
jobService.stop(jobExecution.getId());
jobExecution = jobService.getJobExecution(jobExecution.getId());
assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.STOPPED);
assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.STOPPING);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we wait for STOPPED as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STOPPED only occurs once the batch job has completed. In this test we are just testing that SCDF sets the state to STOPPING. We are not running real jobs here, just creating / modifying the state of the JobExecution.

}

private void verifyJobInstance(long id, String name) throws Exception {
Expand Down
Loading