private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"); } return jobExecution; } }
@Override public Exception getException(String msg) throws Exception { return new NoSuchJobExecutionException(msg); }
@Override public Exception getException(String msg, Throwable t) throws Exception { return new NoSuchJobExecutionException(msg, t); }
private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"); } return jobExecution; }
@RequestMapping(value = "/jobs/executions/{executionId}", method = RequestMethod.GET) public JobExecution findExecution(@PathVariable long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } return jobExecution; }
private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"); } return jobExecution; } }
@RequestMapping(value = "/jobs/executions/{executionId}", method = RequestMethod.GET) public JobExecution findExecution(@PathVariable long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } return jobExecution; }
private JobExecution findExecutionById(Long jobExecutionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(jobExecutionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + jobExecutionId + "]"); } return jobExecution; }
private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"); } return jobExecution; } }
private JobExecution findExecutionById(long executionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"); } return jobExecution; } }
/** * View the details of a single task execution, specified by id. * * @param id the id of the requested {@link JobExecution} * @return the {@link JobExecution} * @throws NoSuchJobExecutionException if the specified job execution for the id does * not exist. */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") @ResponseStatus(HttpStatus.OK) public JobExecutionResource view(@PathVariable("id") long id) throws NoSuchJobExecutionException { TaskJobExecution jobExecution = taskJobService.getJobExecution(id); if (jobExecution == null) { throw new NoSuchJobExecutionException(String.format("No Job Execution with id of %d exits", id)); } return jobAssembler.toResource(jobExecution); }
@RequestMapping(value = "/jobs/executions/{executionId}", method = RequestMethod.GET) public String getStatus(@PathVariable long executionId) throws NoSuchJobExecutionException { if (LOG.isDebugEnabled()) { LOG.debug("Get ExitCode for JobExecution with id: {} ", executionId); } JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution != null) { return jobExecution.getExitStatus().getExitCode(); } else { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } }
@RequestMapping(value = "/jobs/executions/{executionId}", method = RequestMethod.GET) public String getStatus(@PathVariable long executionId) throws NoSuchJobExecutionException { if (LOG.isDebugEnabled()) { LOG.debug("Get ExitCode for JobExecution with id: {} ", executionId); } JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution != null) { return jobExecution.getExitStatus().getExitCode(); } else { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } }
/** * Stop Job Execution by the given executionId. * * @param jobExecutionId the executionId of the job execution to stop */ @RequestMapping(value = { "/{executionId}" }, method = RequestMethod.PUT, params = "stop=true") @ResponseStatus(HttpStatus.OK) public void stopJobExecution(@PathVariable("executionId") long jobExecutionId) throws JobExecutionNotRunningException, NoSuchJobExecutionException { try { jobService.stop(jobExecutionId); } catch (org.springframework.batch.core.launch.JobExecutionNotRunningException e) { throw new JobExecutionNotRunningException(String.format("Job execution with executionId %s is not running.", String.valueOf(jobExecutionId))); } catch (org.springframework.batch.core.launch.NoSuchJobExecutionException e) { throw new NoSuchJobExecutionException(String.format("Could not find jobExecution with id %s", String.valueOf(jobExecutionId))); } }
/** * View the details of a single task execution, specified by id. * * @param id the id of the requested {@link JobExecution} * @return the {@link JobExecution} * @throws NoSuchJobExecutionException if the specified job execution for the id does * not exist. */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") @ResponseStatus(HttpStatus.OK) public JobExecutionResource view(@PathVariable("id") long id) throws NoSuchJobExecutionException { TaskJobExecution jobExecution = taskJobService.getJobExecution(id); if (jobExecution == null) { throw new NoSuchJobExecutionException(String.format("No Job Execution with id of %d exits", id)); } return jobAssembler.toResource(jobExecution); }
@RequestMapping(value = "/jobs/executions/{executionId}/log", method = RequestMethod.GET) public void getLogFile(HttpServletResponse response, @PathVariable long executionId) throws NoSuchJobExecutionException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Get log file for job with executionId: {}", executionId); } String loggingPath = createLoggingPath(); JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } File downloadFile = new File(loggingPath + jobLogFileNameCreator.getName(jobExecution)); InputStream is = new FileInputStream(downloadFile); FileCopyUtils.copy(is, response.getOutputStream()); response.flushBuffer(); }
@RequestMapping(value = "/jobs/executions/{executionId}/log", method = RequestMethod.GET) public void getLogFile(HttpServletResponse response, @PathVariable long executionId) throws NoSuchJobExecutionException, IOException { if (LOG.isDebugEnabled()) { LOG.debug("Get log file for job with executionId: {}", executionId); } String loggingPath = createLoggingPath(); JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("JobExecution with id " + executionId + " not found."); } File downloadFile = new File(loggingPath + jobLogFileNameCreator.getName(jobExecution)); InputStream is = new FileInputStream(downloadFile); FileCopyUtils.copy(is, response.getOutputStream()); response.flushBuffer(); }
@Transactional public void stop(Long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException { JobExecution jobExecution = jobExplorer.getJobExecution(executionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"); } 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); }
@Override public JobExecution getJobExecution(Long jobExecutionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("There is no JobExecution with id=" + jobExecutionId); } jobExecution.setJobInstance(jobInstanceDao.getJobInstance(jobExecution)); try { jobExecution.setExecutionContext(executionContextDao.getExecutionContext(jobExecution)); } catch (Exception e) { logger.info("Cannot load execution context for job execution: " + jobExecution); } stepExecutionDao.addStepExecutions(jobExecution); return jobExecution; }
@Override public JobExecution getJobExecution(Long jobExecutionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("There is no JobExecution with id=" + jobExecutionId); } jobExecution.setJobInstance(jobInstanceDao.getJobInstance(jobExecution)); try { jobExecution.setExecutionContext(executionContextDao.getExecutionContext(jobExecution)); } catch (Exception e) { logger.info("Cannot load execution context for job execution: " + jobExecution); } stepExecutionDao.addStepExecutions(jobExecution); return jobExecution; }