Java 类org.springframework.batch.core.launch.NoSuchJobExecutionException 实例源码

项目:spring-cloud-dashboard    文件:RestControllerAdvice.java   
/**
 * Log the exception message at warn level and stack trace as trace level.
 * Return response status HttpStatus.NOT_FOUND
 */
@ExceptionHandler({NoSuchAppRegistrationException.class,
        NoSuchTaskDefinitionException.class,
        NoSuchTaskExecutionException.class,
        NoSuchJobExecutionException.class,
        NoSuchJobInstanceException.class,
        NoSuchJobException.class,
        NoSuchStepExecutionException.class,
        MetricsMvcEndpoint.NoSuchMetricException.class})
@ResponseStatus(HttpStatus.NOT_FOUND)
@ResponseBody
public VndErrors onNotFoundException(Exception e) {
    String logref = logWarnLevelExceptionMessage(e);
    if (logger.isTraceEnabled()) {
        logTraceLevelStrackTrace(e);
    }
    String msg = getExceptionMessage(e);
    return new VndErrors(logref, msg);
}
项目:spring-cloud-dataflow    文件:RestControllerAdvice.java   
/**
 * Log the exception message at warn level and stack trace as trace level. Return
 * response status HttpStatus.NOT_FOUND
 *
 * @param e one of the exceptions, {@link NoSuchStreamDefinitionException},
 * {@link NoSuchAppRegistrationException}, {@link NoSuchTaskDefinitionException},
 * {@link NoSuchTaskExecutionException}, {@link NoSuchJobExecutionException},
 * {@link NoSuchJobInstanceException}, {@link NoSuchJobException},
 * {@link NoSuchStepExecutionException},
 * {@link MetricsMvcEndpoint.NoSuchMetricException}, {@link NoSuchAppException}, or
 * {@link NoSuchAppInstanceException}
 * @return the error response in JSON format with media type
 * application/vnd.error+json
 */
@ExceptionHandler({ NoSuchStreamDefinitionException.class, NoSuchAppRegistrationException.class,
        NoSuchTaskDefinitionException.class, NoSuchTaskExecutionException.class, NoSuchJobExecutionException.class,
        NoSuchJobInstanceException.class, NoSuchJobException.class, NoSuchStepExecutionException.class,
        MetricsMvcEndpoint.NoSuchMetricException.class, NoSuchAppException.class,
        NoSuchAppInstanceException.class, ApplicationDoesNotExistException.class })
@ResponseStatus(HttpStatus.NOT_FOUND)
@ResponseBody
public VndErrors onNotFoundException(Exception e) {
    String logref = logWarnLevelExceptionMessage(e);
    if (logger.isTraceEnabled()) {
        logTraceLevelStrackTrace(e);
    }
    String msg = getExceptionMessage(e);
    return new VndErrors(logref, msg);
}
项目:spring-cloud-dataflow    文件:DefaultTaskJobService.java   
/**
 * Retrieves Pageable list of {@link JobExecution}s from the JobRepository and matches the
 * data with a task id.
 *
 * @param pageable enumerates the data to be returned.
 * @return List containing {@link TaskJobExecution}s.
 */
@Override
public List<TaskJobExecution> listJobExecutions(Pageable pageable) throws NoSuchJobExecutionException {
    Assert.notNull(pageable, "pageable must not be null");
    List<JobExecution> jobExecutions = new ArrayList<>(
            jobService.listJobExecutions(pageable.getOffset(), pageable.getPageSize()));
    for (JobExecution jobExecution : jobExecutions) {
        Collection<StepExecution> stepExecutions = jobService.getStepExecutions(jobExecution.getId());
        List<StepExecution> validStepExecutions = new ArrayList<>();
        for (StepExecution stepExecution : stepExecutions) {
            if (stepExecution.getId() != null) {
                validStepExecutions.add(stepExecution);
            }
        }
        jobExecution.addStepExecutions(validStepExecutions);
    }
    return getTaskJobExecutionsForList(jobExecutions);
}
项目:spring-cloud-dataflow    文件:DefaultTaskJobService.java   
@Override
public void restartJobExecution(long jobExecutionId) throws NoSuchJobExecutionException {
    logger.info("Restarting Job with Id " + jobExecutionId);

    final TaskJobExecution taskJobExecution = this.getJobExecution(jobExecutionId);
    final JobExecution jobExecution = taskJobExecution.getJobExecution();

    if (!JobUtils.isJobExecutionRestartable(taskJobExecution.getJobExecution())) {
        throw new JobNotRestartableException(
                String.format("JobExecution with Id '%s' and state '%s' is not " + "restartable.",
                        jobExecution.getId(), taskJobExecution.getJobExecution().getStatus()));
    }

    TaskExecution taskExecution = this.taskExplorer.getTaskExecution(taskJobExecution.getTaskId());

    TaskDefinition taskDefinition = this.taskDefinitionRepository.findOne(taskExecution.getTaskName());

    if (taskDefinition == null) {
        throw new NoSuchTaskDefinitionException(taskExecution.getTaskName());
    }

    taskService.executeTask(taskDefinition.getName(), taskDefinition.getProperties(), taskExecution.getArguments());
}
项目:spring-cloud-dataflow    文件:JobExecutionController.java   
/**
 * 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);
}
项目:spring-batch-tools    文件:BatchController.java   
@RequestMapping("/executions/{executionId}/stop")
@ResponseBody
public JobExecution stopExecution(@PathVariable("executionId") final long executionId) throws NoSuchJobExecutionException,
        JobExecutionNotRunningException {
    batchOperator.stop(executionId);

    return execution(executionId);
}
项目:spring-batch-tools    文件:BatchController.java   
@RequestMapping("/executions/{executionId}/restart")
@ResponseBody
public JobExecution restartExecution(@PathVariable("executionId") final long executionId) throws JobInstanceAlreadyCompleteException,
        NoSuchJobExecutionException, NoSuchJobException, JobRestartException, JobParametersInvalidException,
        JobExecutionAlreadyRunningException {
    final long restartedExecutionId = batchOperator.restart(executionId);

    return execution(restartedExecutionId);
}
项目:spring-batch-tools    文件:BatchOperatorImpl.java   
@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);
}
项目:spring-batch-tools    文件:BatchOperatorImpl.java   
@Override
public long restart(final long executionId) throws JobInstanceAlreadyCompleteException, NoSuchJobExecutionException,
        NoSuchJobException, JobRestartException, JobParametersInvalidException, JobExecutionAlreadyRunningException {
    final JobExecution jobExecution = execution(executionId);
    final String jobName = jobExecution.getJobInstance().getJobName();
    final Job job = jobRegistry.getJob(jobName);
    final JobParameters parameters = jobExecution.getJobParameters();

    LOG.info("Attempting to resume job with name={} and parameters={}", jobName, parameters);
    return jobLauncher.run(job, parameters).getId();
}
项目:spring-batch-tools    文件:BatchOperatorImpl.java   
@Override
public void abandonJob(final long executionId) throws NoSuchJobExecutionException, JobExecutionAlreadyRunningException {
    final JobExecution execution = execution(executionId);

    if (!ABANDONABLE.contains(execution.getStatus())) {
        throw new JobExecutionAlreadyRunningException(String.format("JobExecution #%s is in status %s and therefore cannot be aborted",
                execution.getId(), execution.getStatus()));
    }

    LOG.info("Abandoning job execution: {}", execution);
    execution.upgradeStatus(BatchStatus.ABANDONED);
    execution.setEndTime(new Date());
    jobRepository.update(execution);
}
项目:saos    文件:SaosJobServiceAdapter.java   
public JobExecution restart(Long jobExecutionId)
        throws NoSuchJobExecutionException,
        JobExecutionAlreadyRunningException, JobRestartException,
        JobInstanceAlreadyCompleteException, NoSuchJobException,
        JobParametersInvalidException {
    return simpleJobService.restart(jobExecutionId);
}
项目:spring-boot-starter-batch-web    文件:JobMonitoringController.java   
@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;
}
项目:spring-boot-starter-batch-web    文件:JobOperationsController.java   
@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.");
    }
}
项目:spring-boot-starter-batch-web    文件:JobOperationsController.java   
@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();
}
项目:spring-boot-starter-batch-web    文件:JobOperationsController.java   
@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();
}
项目:spring-cloud-dataflow    文件:DefaultTaskJobService.java   
@Override
public void stopJobExecution(long jobExecutionId)
        throws NoSuchJobExecutionException, JobExecutionNotRunningException {
    this.jobService.stop(jobExecutionId).getStatus();
}
项目:spring-batch-tools    文件:BatchOperatorImpl.java   
private JobExecution execution(final long executionId) throws NoSuchJobExecutionException {
    return Optional.ofNullable(jobExplorer.getJobExecution(executionId)).orElseThrow(
            () -> new NoSuchJobExecutionException("No JobExecution found for id: [" + executionId + "]"));
}
项目:spring-batch-tools    文件:BatchOperator.java   
long restart(long executionId) throws JobInstanceAlreadyCompleteException, NoSuchJobExecutionException, NoSuchJobException,
JobRestartException, JobParametersInvalidException, JobExecutionAlreadyRunningException;
项目:spring-batch-tools    文件:BatchOperatorImplTest.java   
@Test(expected = NoSuchJobExecutionException.class)
public void stopExecutionNotFoundThrows() throws Exception {
    batchOperator.stop(1L);
}
项目:spring-batch-tools    文件:BatchOperatorImplTest.java   
@Test(expected = NoSuchJobExecutionException.class)
public void restartExecutionNotFoundThrows() throws Exception {
    batchOperator.restart(1L);
}
项目:spring-batch-tools    文件:BatchOperatorImplTest.java   
@Test(expected = NoSuchJobExecutionException.class)
public void abandonJobExecutionNotFound() throws Exception {
    batchOperator.abandonJob(1L);
}
项目:saos    文件:SaosJobServiceAdapter.java   
public Collection<StepExecution> getStepExecutions(Long jobExecutionId)
        throws NoSuchJobExecutionException {
    return simpleJobService.getStepExecutions(jobExecutionId);
}
项目:saos    文件:SaosJobServiceAdapter.java   
public JobExecution stop(Long jobExecutionId)
        throws NoSuchJobExecutionException, JobExecutionNotRunningException {
    return simpleJobService.stop(jobExecutionId);
}
项目:saos    文件:SaosJobServiceAdapter.java   
public JobExecution abandon(Long jobExecutionId)
        throws NoSuchJobExecutionException,
        JobExecutionAlreadyRunningException {
    return simpleJobService.abandon(jobExecutionId);
}
项目:saos    文件:SaosJobServiceAdapter.java   
public JobExecution getJobExecution(Long jobExecutionId)
        throws NoSuchJobExecutionException {
    return simpleJobService.getJobExecution(jobExecutionId);
}
项目:saos    文件:SaosJobServiceAdapter.java   
public StepExecution getStepExecution(Long jobExecutionId,
        Long stepExecutionId) throws NoSuchJobExecutionException,
        NoSuchStepExecutionException {
    return simpleJobService.getStepExecution(jobExecutionId,
            stepExecutionId);
}
项目:spring-boot-starter-batch-web    文件:JobMonitoringController.java   
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoSuchJobExecutionException.class)
public String handleNotFound(Exception ex) {
    LOG.warn("JobExecution not found.",ex);
    return ex.getMessage();
}
项目:spring-boot-starter-batch-web    文件:JobOperationsController.java   
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler({NoSuchJobException.class, NoSuchJobExecutionException.class, JobStartException.class})
public String handleNotFound(Exception ex) {
    LOG.warn("Job or JobExecution not found.",ex);
    return ex.getMessage();
}
项目:spring-cloud-dataflow    文件:JobExecutionController.java   
/**
 * Return a page-able list of {@link JobExecutionResource} defined jobs.
 *
 * @param pageable page-able collection of {@code TaskJobExecution}s.
 * @param assembler for the {@link TaskJobExecution}s
 * @return a list of Task/Job executions
 * @throws NoSuchJobExecutionException in the event that a job execution id specified
 * is not present when looking up stepExecutions for the result.
 */
@RequestMapping(value = "", method = RequestMethod.GET, produces = "application/json")
@ResponseStatus(HttpStatus.OK)
public PagedResources<JobExecutionResource> list(Pageable pageable,
        PagedResourcesAssembler<TaskJobExecution> assembler) throws NoSuchJobExecutionException {
    List<TaskJobExecution> jobExecutions = taskJobService.listJobExecutions(pageable);
    Page<TaskJobExecution> page = new PageImpl<>(jobExecutions, pageable, taskJobService.countJobExecutions());
    return assembler.toResource(page, jobAssembler);
}
项目:spring-cloud-dataflow    文件:JobExecutionController.java   
/**
 * 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);
}
项目:spring-cloud-dataflow    文件:JobExecutionController.java   
/**
 * Restart the Job Execution with the given jobExecutionId. Please be aware that you
 * must provide the request parameter {@code restart=true} in order to invoke this
 * endpoint.
 *
 * @param jobExecutionId the executionId of the job execution to restart
 * @throws NoSuchJobExecutionException if the job execution for the jobExecutionId
 * specified does not exist.
 */
@RequestMapping(value = { "/{executionId}" }, method = RequestMethod.PUT, params = "restart=true")
@ResponseStatus(HttpStatus.OK)
public void restartJobExecution(@PathVariable("executionId") long jobExecutionId)
        throws NoSuchJobExecutionException {
    taskJobService.restartJobExecution(jobExecutionId);
}
项目:spring-cloud-dataflow    文件:JobStepExecutionController.java   
/**
 * List all step executions.
 *
 * @param id the {@link JobExecution}.
 * @param pageable the pagination information.
 * @param assembler the resource assembler for step executions.
 * @return Collection of {@link StepExecutionResource} for the given jobExecutionId.
 * @throws NoSuchJobExecutionException if the job execution for the id specified does
 * not exist.
 */
@RequestMapping(value = { "" }, method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public PagedResources<StepExecutionResource> stepExecutions(@PathVariable("jobExecutionId") long id,
        Pageable pageable, PagedResourcesAssembler<StepExecution> assembler) throws NoSuchJobExecutionException {
    List<StepExecution> result;
    result = new ArrayList<>(jobService.getStepExecutions(id));
    Page<StepExecution> page = new PageImpl<>(result, pageable, result.size());
    return assembler.toResource(page, stepAssembler);
}
项目:spring-cloud-dataflow    文件:JobStepExecutionController.java   
/**
 * Retrieve a specific {@link StepExecutionResource}.
 *
 * @param id the {@link JobExecution} id.
 * @param stepId the {@link StepExecution} id.
 * @return Collection of {@link StepExecutionResource} for the given jobExecutionId.
 * @throws NoSuchStepExecutionException if the stepId specified does not exist.
 * @throws NoSuchJobExecutionException if the job execution for the id specified does
 * not exist.
 */
@RequestMapping(value = { "/{stepExecutionId}" }, method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public StepExecutionResource getStepExecution(@PathVariable("jobExecutionId") Long id,
        @PathVariable("stepExecutionId") Long stepId)
        throws NoSuchStepExecutionException, NoSuchJobExecutionException {
    return stepAssembler.toResource(jobService.getStepExecution(id, stepId));
}
项目:spring-cloud-dataflow    文件:TaskJobService.java   
/**
 * Retrieves Pageable list of {@link JobExecution}s from the JobRepository and matches the
 * data with a task id.
 *
 * @param pageable enumerates the data to be returned.
 * @return List containing {@link TaskJobExecution}s.
 * @throws NoSuchJobExecutionException in the event that a job execution id specified is
 * not present when looking up stepExecutions for the result.
 */
List<TaskJobExecution> listJobExecutions(Pageable pageable) throws NoSuchJobExecutionException;
项目:spring-cloud-dataflow    文件:TaskJobService.java   
/**
 * Retrieves a JobExecution from the JobRepository and matches it with a task id.
 *
 * @param id the id of the {@link JobExecution}
 * @return the {@link TaskJobExecution}s associated with the id.
 * @throws NoSuchJobExecutionException if the specified job execution for the id does not
 * exist.
 */
TaskJobExecution getJobExecution(long id) throws NoSuchJobExecutionException;
项目:spring-cloud-dataflow    文件:TaskJobService.java   
/**
 * Restarts a {@link JobExecution} IF the respective {@link JobExecution} is actually
 * deemed restartable. Otherwise a {@link JobNotRestartableException} is being thrown.
 *
 * @param jobExecutionId The id of the JobExecution to restart.
 * @throws NoSuchJobExecutionException if the JobExecution for the provided id does not
 * exist.
 */
void restartJobExecution(long jobExecutionId) throws NoSuchJobExecutionException;
项目:spring-cloud-dataflow    文件:TaskJobService.java   
/**
 * 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;
项目:spring-cloud-dataflow    文件:DefaultTaskJobService.java   
/**
 * Retrieves a JobExecution from the JobRepository and matches it with a task id.
 *
 * @param id the id of the {@link JobExecution}
 * @return the {@link TaskJobExecution}s associated with the id.
 */
@Override
public TaskJobExecution getJobExecution(long id) throws NoSuchJobExecutionException {
    JobExecution jobExecution = jobService.getJobExecution(id);
    return getTaskJobExecution(jobExecution);
}
项目:egovframework.rte.root    文件:EgovBatchRunner.java   
/**
 * 정지, 종료되었거나 실패한 Batch Job을 재시작한다.
 * @param jobExecutionId : JobExecution의 ID
 * @return Long: JobExecution의 ID
 * @throws JobInstanceAlreadyCompleteException
 * @throws NoSuchJobExecutionException
 * @throws NoSuchJobException
 * @throws JobRestartException
 * @throws JobParametersInvalidException
 */
public Long restart(Long jobExecutionId) throws JobInstanceAlreadyCompleteException, NoSuchJobExecutionException, NoSuchJobException, JobRestartException, JobParametersInvalidException {
    return jobOperator.restart(jobExecutionId);
}
项目:egovframework.rte.root    文件:EgovBatchRunner.java   
/**
 * 실행 중인 Batch Job을 정지한다.
 * @param jobExecutionId : JobExecution의 ID
 * @throws NoSuchJobExecutionException
 * @throws JobExecutionNotRunningException
 */
public void stop(Long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException  {
    jobOperator.stop(jobExecutionId);
}