Package org.springframework.batch.core

Examples of org.springframework.batch.core.JobExecution


      throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException {

    Assert.notNull(jobName, "Job name must not be null.");
    Assert.notNull(jobParameters, "JobParameters must not be null.");

    JobExecution jobExecution = null;
    try {
      CreateJobExecutionReq request = JobRepositoryRpcFactory.buildCreateJobExecutionReq(jobName, jobParameters);
      CreateJobExecutionRes response = (CreateJobExecutionRes) getAppmasterScOperations().doMindRequest(request);
      jobExecution = JobRepositoryRpcFactory.convertJobExecutionType(response.jobExecution);
    } catch (Exception e) {
View Full Code Here


  @Override
  public JobExecution createJobExecution(JobInstance jobInstance, JobParameters jobParameters, String jobConfigurationLocation) {
    Assert.notNull(jobInstance, "Job instance must not be null.");
    Assert.notNull(jobParameters, "JobParameters must not be null.");

    JobExecution jobExecution = null;
    try {
      CreateJobExecutionWithJobInstanceReq request = JobRepositoryRpcFactory.buildCreateJobExecutionWithJobInstanceReq(jobInstance, jobParameters, jobConfigurationLocation);
      CreateJobExecutionWithJobInstanceRes response = (CreateJobExecutionWithJobInstanceRes) getAppmasterScOperations().doMindRequest(request);
      jobExecution = JobRepositoryRpcFactory.convertJobExecutionType(response.jobExecution);
    } catch (Exception e) {
View Full Code Here

        JobParametersBuilder builder = new JobParametersBuilder();
        builder.addString("stringKey", "stringValue").addLong("longKey", 1L).addDouble("doubleKey", 1.1).addDate(
                "dateKey", new Date(1L));
        JobParameters jobParams = builder.toJobParameters();

        JobExecution firstExecution = jobRepository.createJobExecution(job.getName(), jobParams);
        firstExecution.setStartTime(new Date());
        assertNotNull(firstExecution.getLastUpdated());

        assertEquals(job.getName(), firstExecution.getJobInstance().getJobName());

        jobRepository.update(firstExecution);
        firstExecution.setEndTime(new Date());
        jobRepository.update(firstExecution);
        JobExecution secondExecution = jobRepository.createJobExecution(job.getName(), jobParams);

        assertEquals(firstExecution.getJobInstance(), secondExecution.getJobInstance());
        assertEquals(job.getName(), secondExecution.getJobInstance().getJobName());
    }
View Full Code Here

        map.put(entry.getKey(), new JobParameter((String)entry.getValue().parameter));
      }
    }
    JobParameters jobParameters = new JobParameters(map);
    //throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException
    JobExecution jobExecution = null;
    try {
      jobExecution = jobRepository.createJobExecution(jobName, jobParameters);
    } catch (JobExecutionAlreadyRunningException e) {
      e.printStackTrace();
    } catch (JobRestartException e) {
View Full Code Here

    return response;
  }

  private BaseResponseObject handleUpdateWithJobExecutionReq(UpdateWithJobExecutionReq request) {
    UpdateWithJobExecutionRes response = null;
    JobExecution jobExecution = JobRepositoryRpcFactory.convertJobExecutionType(request.jobExecution);
    jobRepository.update(jobExecution);
    response = new UpdateWithJobExecutionRes();
    response.id = jobExecution.getId();
    response.version = jobExecution.getVersion();
    return response;
  }
View Full Code Here

        map.put(entry.getKey(), new JobParameter((String)entry.getValue().parameter));
      }
    }
    JobParameters jobParameters = new JobParameters(map);

    JobExecution lastJobExecution = jobRepository.getLastJobExecution(jobName, jobParameters);

    response = new GetLastJobExecutionRes();
    response.jobExecution = JobRepositoryRpcFactory.convertJobExecutionType(lastJobExecution);

    return response;
View Full Code Here

    try {
      if(request.stepExecution != null) {
        StepExecution stepExecution = JobRepositoryRpcFactory.convertStepExecutionType(request.stepExecution);
        jobRepository.updateExecutionContext(stepExecution);
      } else if(request.jobExecution != null) {
        JobExecution jobExecution = JobRepositoryRpcFactory.convertJobExecutionType(request.jobExecution);
        jobRepository.updateExecutionContext(jobExecution);
      }
      response = new UpdateExecutionContextRes();
    } catch (Exception e) {
      log.error("error handling command", e);
View Full Code Here

    @Test
    public void testCreateAndFindWithNoStartDate() throws Exception {
        job.setRestartable(true);

        JobExecution firstExecution = jobRepository.createJobExecution(job.getName(), jobParameters);
        firstExecution.setStartTime(new Date(0));
        firstExecution.setEndTime(new Date(1));
        jobRepository.update(firstExecution);
        JobExecution secondExecution = jobRepository.createJobExecution(job.getName(), jobParameters);

        assertEquals(firstExecution.getJobInstance(), secondExecution.getJobInstance());
        assertEquals(job.getName(), secondExecution.getJobInstance().getJobName());
    }
View Full Code Here

    public void testGetStepExecutionCountAndLastStepExecution() throws Exception {
        job.setRestartable(true);
        StepSupport step = new StepSupport("restartedStep");

        // first execution
        JobExecution firstJobExec = jobRepository.createJobExecution(job.getName(), jobParameters);
        StepExecution firstStepExec = new StepExecution(step.getName(), firstJobExec);
        jobRepository.add(firstStepExec);

        assertEquals(1, jobRepository.getStepExecutionCount(firstJobExec.getJobInstance(), step.getName()));
        assertEquals(firstStepExec, jobRepository.getLastStepExecution(firstJobExec.getJobInstance(), step.getName()));

        // first execution failed
        firstJobExec.setStartTime(new Date(4));
        firstStepExec.setStartTime(new Date(5));
        firstStepExec.setStatus(BatchStatus.FAILED);
        firstStepExec.setEndTime(new Date(6));
        jobRepository.update(firstStepExec);
        firstJobExec.setStatus(BatchStatus.FAILED);
        firstJobExec.setEndTime(new Date(7));
        jobRepository.update(firstJobExec);

        // second execution
        JobExecution secondJobExec = jobRepository.createJobExecution(job.getName(), jobParameters);
        StepExecution secondStepExec = new StepExecution(step.getName(), secondJobExec);
        jobRepository.add(secondStepExec);

        assertEquals(2, jobRepository.getStepExecutionCount(secondJobExec.getJobInstance(), step.getName()));
        assertEquals(secondStepExec, jobRepository.getLastStepExecution(secondJobExec.getJobInstance(), step.getName()));
    }
View Full Code Here

    @Test
    public void testSaveExecutionContext() throws Exception {
        ExecutionContext ctx = new ExecutionContext();
        ctx.putLong("crashedPosition", 7);
        JobExecution jobExec = jobRepository.createJobExecution(job.getName(), jobParameters);
        jobExec.setStartTime(new Date(0));
        jobExec.setExecutionContext(ctx);
        Step step = new StepSupport("step1");
        StepExecution stepExec = new StepExecution(step.getName(), jobExec);
        stepExec.setExecutionContext(ctx);

        jobRepository.add(stepExec);

        StepExecution retrievedStepExec = jobRepository.getLastStepExecution(jobExec.getJobInstance(), step.getName());
        assertEquals(stepExec, retrievedStepExec);
        assertEquals(ctx, retrievedStepExec.getExecutionContext());

    }
View Full Code Here

TOP

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

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.