Package org.springframework.batch.core

Examples of org.springframework.batch.core.BatchStatus


    Assert.notNull(result, "To aggregate into a result it must be non-null.");
    if (executions == null) {
      return;
    }
    for (StepExecution stepExecution : executions) {
      BatchStatus status = stepExecution.getStatus();
      result.setStatus(BatchStatus.max(result.getStatus(), status));
      result.setExitStatus(result.getExitStatus().and(stepExecution.getExitStatus()));
      result.setFilterCount(result.getFilterCount() + stepExecution.getFilterCount());
      result.setProcessSkipCount(result.getProcessSkipCount() + stepExecution.getProcessSkipCount());
      result.setCommitCount(result.getCommitCount() + stepExecution.getCommitCount());
View Full Code Here


    }

    int numStepExecutions = jobExecution.getStepExecutions().size();
    StepExecution stepExecution = jobExecution.getStepExecutions().iterator().next();
    String stepName = stepExecution.getStepName();
    BatchStatus stepExecutionStatus = stepExecution.getStatus();
    BatchStatus jobExecutionStatus = jobExecution.getStatus();

    assertTrue("Should only be one StepExecution but got: " + numStepExecutions, numStepExecutions == 1);
    assertTrue("Step name for execution should be step1 but got: " + stepName, "step1".equals(stepName));
    assertTrue("Step execution status should be STOPPED but got: " + stepExecutionStatus, stepExecutionStatus.equals(BatchStatus.STOPPED));
    assertTrue("Job execution status should be STOPPED but got:" + jobExecutionStatus, jobExecutionStatus.equals(BatchStatus.STOPPED));

    JobExecution restartJobExecution = jobLauncher.run(job, new JobParametersBuilder()
        .addLong("test", 1L)
        .toJobParameters());

    while(restartJobExecution.isRunning()) {
      // wait for async launched job to complete execution
    }

    int restartNumStepExecutions = restartJobExecution.getStepExecutions().size();
    assertTrue("Should be two StepExecution's on restart but got: " + restartNumStepExecutions, restartNumStepExecutions == 2);

    for(StepExecution restartStepExecution : restartJobExecution.getStepExecutions()) {
      BatchStatus restartStepExecutionStatus = restartStepExecution.getStatus();

      assertTrue("Step execution status should be COMPLETED but got: " + restartStepExecutionStatus,
          restartStepExecutionStatus.equals(BatchStatus.COMPLETED));
    }

    BatchStatus restartJobExecutionStatus = restartJobExecution.getStatus();
    assertTrue("Job execution status should be COMPLETED but got:" + restartJobExecutionStatus,
        restartJobExecutionStatus.equals(BatchStatus.COMPLETED));
  }
View Full Code Here

    Assert.notNull(result, "To aggregate into a result it must be non-null.");
    if (executions == null) {
      return;
    }
    for (StepExecution stepExecution : executions) {
      BatchStatus status = stepExecution.getStatus();
      result.setStatus(BatchStatus.max(result.getStatus(), status));
      result.setCommitCount(result.getCommitCount() + stepExecution.getCommitCount());
      result.setRollbackCount(result.getRollbackCount() + stepExecution.getRollbackCount());
      result.setReadCount(result.getReadCount() + stepExecution.getReadCount());
      result.setReadSkipCount(result.getReadSkipCount() + stepExecution.getReadSkipCount());
View Full Code Here

   * an earlier failure
   */
  protected boolean shouldStart(StepExecution lastStepExecution, JobExecution jobExecution, Step step)
      throws JobRestartException, StartLimitExceededException {

    BatchStatus stepStatus;
    if (lastStepExecution == null) {
      stepStatus = BatchStatus.STARTING;
    }
    else {
      stepStatus = lastStepExecution.getStatus();
View Full Code Here

    JobExecution jobExecution = findExecutionById(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.
    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);
View Full Code Here

  JobExecutionNotRunningException, JobSecurityException {
    org.springframework.batch.core.JobExecution jobExecution = jobExplorer.getJobExecution(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.
    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);
View Full Code Here

      this.fail = fail;
    }

    @Override
    public void execute(StepExecution stepExecution) throws JobInterruptedException {
      BatchStatus status = BatchStatus.COMPLETED;
      ExitStatus exitStatus = ExitStatus.COMPLETED;
      if (fail) {
        status = BatchStatus.FAILED;
        exitStatus = ExitStatus.FAILED;
      }
View Full Code Here

        if (execution.isRunning()) {
          throw new JobExecutionAlreadyRunningException("A job execution for this job is already running: "
              + jobInstance);
        }

        BatchStatus status = execution.getStatus();
        if (execution.getJobParameters().getParameters().size() > 0 && (status == BatchStatus.COMPLETED || status == BatchStatus.ABANDONED)) {
          throw new JobInstanceAlreadyCompleteException(
              "A job instance already exists and is complete for parameters=" + jobParameters
              + ".  If you want to run this job again, change the parameters.");
        }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testHandleRestartSunnyDay() throws Exception {

    BatchStatus status = jobExecution.getStatus();
 
    EndState state = new EndState(FlowExecutionStatus.UNKNOWN, "end");
    state.handle(new JobFlowExecutorSupport() {
      @Override
      public JobExecution getJobExecution() {
View Full Code Here

   * an earlier failure
   */
  @Override
  protected boolean shouldStart(StepExecution lastStepExecution, JobExecution jobExecution, Step step)
      throws JobRestartException, StartLimitExceededException {
    BatchStatus stepStatus;
    String restartStep = null;
    if (lastStepExecution == null) {
      jobExecution.getExecutionContext().put("batch.startedStep", step.getName());
      stepStatus = BatchStatus.STARTING;
    }
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.BatchStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.