/** * Log the exception message at warn level and stack trace as trace level. Return * response status HttpStatus.UNPROCESSABLE_ENTITY * * @param e one of the exceptions, {@link JobNotRestartableException} or * {@link JobExecutionNotRunningException} * @return the error response in JSON format with media type * application/vnd.error+json */ @ExceptionHandler({ JobNotRestartableException.class, JobExecutionNotRunningException.class }) @ResponseStatus(HttpStatus.UNPROCESSABLE_ENTITY) @ResponseBody public VndErrors onUnprocessableEntityException(Exception e) { String logref = logWarnLevelExceptionMessage(e); if (logger.isTraceEnabled()) { logTraceLevelStrackTrace(e); } String msg = getExceptionMessage(e); return new VndErrors(logref, msg); }
@RequestMapping("/executions/{executionId}/stop") @ResponseBody public JobExecution stopExecution(@PathVariable("executionId") final long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException { batchOperator.stop(executionId); return execution(executionId); }
@Override public void stop(final long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException { final JobExecution jobExecution = execution(executionId); // 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. final BatchStatus status = jobExecution.getStatus(); if (!(status == BatchStatus.STARTED || status == BatchStatus.STARTING)) { throw new JobExecutionNotRunningException("JobExecution must be running so that it can be stopped: " + jobExecution); } jobExecution.setStatus(BatchStatus.STOPPING); jobRepository.update(jobExecution); }
@RequestMapping(value = "/jobs/executions/{executionId}", method = RequestMethod.DELETE) public String stop(@PathVariable long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException { if (LOG.isDebugEnabled()) { LOG.debug("Stop JobExecution with id: " + executionId); } Boolean successful = jobOperator.stop(executionId); return successful.toString(); }
@Override public void stopJobExecution(long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException { this.jobService.stop(jobExecutionId).getStatus(); }
@Test(expected = JobExecutionNotRunningException.class) public void stopExecutionNotRunningThrows() throws Exception { when(jobExplorer.getJobExecution(1L)).thenReturn(execution); when(execution.getStatus()).thenReturn(BatchStatus.COMPLETED); batchOperator.stop(1L); }
public JobExecution stop(Long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException { return simpleJobService.stop(jobExecutionId); }
@ResponseStatus(HttpStatus.CONFLICT) @ExceptionHandler(JobExecutionNotRunningException.class) public String handleNotRunning(Exception ex) { LOG.warn("JobExecution is not running.",ex); return ex.getMessage(); }
/** * Stop a Job Execution with the given jobExecutionId. Please be aware that you must * provide the request parameter {@code stop=true} in order to invoke this endpoint. * * @param jobExecutionId the executionId of the job execution to stop. * @throws JobExecutionNotRunningException if a stop is requested on a job that is not * running. * @throws NoSuchJobExecutionException if the job execution id specified does not * exist. */ @RequestMapping(value = { "/{executionId}" }, method = RequestMethod.PUT, params = "stop=true") @ResponseStatus(HttpStatus.OK) public void stopJobExecution(@PathVariable("executionId") long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException { taskJobService.stopJobExecution(jobExecutionId); }
/** * Requests a {@link JobExecution} to stop. * <p> * Please remember, that calling this method only requests a job execution to stop * processing. This method does not guarantee a {@link JobExecution} to stop. It is the * responsibility of the implementor of the {@link Job} to react to that request. * Furthermore, this method does not interfere with the associated {@link TaskExecution}. * * @param jobExecutionId The id of the {@link JobExecution} to stop * @throws NoSuchJobExecutionException if no job execution exists for the jobExecutionId. * @throws JobExecutionNotRunningException if a stop is requested on a job that is not * running. * @see org.springframework.batch.admin.service.JobService#stop(Long) */ void stopJobExecution(long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException;
/** * 실행 중인 Batch Job을 정지한다. * @param jobExecutionId : JobExecution의 ID * @throws NoSuchJobExecutionException * @throws JobExecutionNotRunningException */ public void stop(Long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException { jobOperator.stop(jobExecutionId); }
void stop(long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException;