Exemplo n.º 1
0
 private JobExecution getLastFailedJobExecution(String jobIdentifier) {
   List<JobExecution> jobExecutions =
       getJobExecutionsWithStatusGreaterThan(jobIdentifier, BatchStatus.STOPPING);
   if (jobExecutions.isEmpty()) {
     return null;
   }
   return jobExecutions.get(0);
 }
Exemplo n.º 2
0
  /**
   * @param job the job that we need to find the next parameters for
   * @return the next job parameters if they can be located
   * @throws JobParametersNotFoundException if there is a problem
   */
  private JobParameters getNextJobParameters(Job job) throws JobParametersNotFoundException {
    String jobIdentifier = job.getName();
    JobParameters jobParameters;
    List<JobInstance> lastInstances = jobExplorer.getJobInstances(jobIdentifier, 0, 1);

    JobParametersIncrementer incrementer = job.getJobParametersIncrementer();
    if (incrementer == null) {
      throw new JobParametersNotFoundException(
          "No job parameters incrementer found for job=" + jobIdentifier);
    }

    if (lastInstances.isEmpty()) {
      jobParameters = incrementer.getNext(new JobParameters());
      if (jobParameters == null) {
        throw new JobParametersNotFoundException(
            "No bootstrap parameters found from incrementer for job=" + jobIdentifier);
      }
    } else {
      jobParameters = incrementer.getNext(lastInstances.get(0).getJobParameters());
    }
    return jobParameters;
  }