Example usage for org.springframework.batch.core Job getName

List of usage examples for org.springframework.batch.core Job getName

Introduction

In this page you can find the example usage for org.springframework.batch.core Job getName.

Prototype

String getName();

Source Link

Usage

From source file:org.springframework.yarn.batch.support.YarnJobLauncher.java

/**
 * Get next job parameters for a job using {@link JobParametersIncrementer}.
 *
 * @param job the job that we need to find the next parameters for
 * @param fail suppress exception/*ww w . j a v a2s.com*/
 * @return the next job parameters if they can be located
 * @throws JobParametersNotFoundException if there is a problem
 */
private JobParameters getNextJobParameters(Job job, boolean fail) 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 {
        List<JobExecution> lastExecutions = jobExplorer.getJobExecutions(lastInstances.get(0));
        jobParameters = incrementer.getNext(lastExecutions.get(0).getJobParameters());
    }
    return jobParameters;
}