Java 类org.springframework.batch.core.JobParametersIncrementer 实例源码

项目:spring-boot-starter-batch-web    文件:JobOperationsController.java   
/**
 * Borrowed from CommandLineJobRunner.
 * @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 (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;
}
项目:egovframework.rte.root    文件:EgovCommandLineRunner.java   
/**
 * 다음 실행 될 Batch Job의 Job Parameter를 생성한다.
 * 
 * @param job
 * @return JobParameters
 * @throws JobParametersNotFoundException 
 */
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;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JobLauncherCommandLineRunner.java   
private JobParameters getNextJobParameters(Job job,
        JobParameters additionalParameters) {
    String name = job.getName();
    JobParameters parameters = new JobParameters();
    List<JobInstance> lastInstances = this.jobExplorer.getJobInstances(name, 0, 1);
    JobParametersIncrementer incrementer = job.getJobParametersIncrementer();
    Map<String, JobParameter> additionals = additionalParameters.getParameters();
    if (lastInstances.isEmpty()) {
        // Start from a completely clean sheet
        if (incrementer != null) {
            parameters = incrementer.getNext(new JobParameters());
        }
    }
    else {
        List<JobExecution> previousExecutions = this.jobExplorer
                .getJobExecutions(lastInstances.get(0));
        JobExecution previousExecution = previousExecutions.get(0);
        if (previousExecution == null) {
            // Normally this will not happen - an instance exists with no executions
            if (incrementer != null) {
                parameters = incrementer.getNext(new JobParameters());
            }
        }
        else if (isStoppedOrFailed(previousExecution) && job.isRestartable()) {
            // Retry a failed or stopped execution
            parameters = previousExecution.getJobParameters();
            // Non-identifying additional parameters can be removed to a retry
            removeNonIdentifying(additionals);
        }
        else if (incrementer != null) {
            // New instance so increment the parameters if we can
            parameters = incrementer.getNext(previousExecution.getJobParameters());
        }
    }
    return merge(parameters, additionals);
}
项目:spring-boot-concourse    文件:JobLauncherCommandLineRunner.java   
private JobParameters getNextJobParameters(Job job,
        JobParameters additionalParameters) {
    String name = job.getName();
    JobParameters parameters = new JobParameters();
    List<JobInstance> lastInstances = this.jobExplorer.getJobInstances(name, 0, 1);
    JobParametersIncrementer incrementer = job.getJobParametersIncrementer();
    Map<String, JobParameter> additionals = additionalParameters.getParameters();
    if (lastInstances.isEmpty()) {
        // Start from a completely clean sheet
        if (incrementer != null) {
            parameters = incrementer.getNext(new JobParameters());
        }
    }
    else {
        List<JobExecution> previousExecutions = this.jobExplorer
                .getJobExecutions(lastInstances.get(0));
        JobExecution previousExecution = previousExecutions.get(0);
        if (previousExecution == null) {
            // Normally this will not happen - an instance exists with no executions
            if (incrementer != null) {
                parameters = incrementer.getNext(new JobParameters());
            }
        }
        else if (isStoppedOrFailed(previousExecution) && job.isRestartable()) {
            // Retry a failed or stopped execution
            parameters = previousExecution.getJobParameters();
            // Non-identifying additional parameters can be removed to a retry
            removeNonIdentifying(additionals);
        }
        else if (incrementer != null) {
            // New instance so increment the parameters if we can
            parameters = incrementer.getNext(previousExecution.getJobParameters());
        }
    }
    return merge(parameters, additionals);
}
项目:contestparser    文件:JobLauncherCommandLineRunner.java   
private JobParameters getNextJobParameters(Job job,
        JobParameters additionalParameters) {
    String name = job.getName();
    JobParameters parameters = new JobParameters();
    List<JobInstance> lastInstances = this.jobExplorer.getJobInstances(name, 0, 1);
    JobParametersIncrementer incrementer = job.getJobParametersIncrementer();
    Map<String, JobParameter> additionals = additionalParameters.getParameters();
    if (lastInstances.isEmpty()) {
        // Start from a completely clean sheet
        if (incrementer != null) {
            parameters = incrementer.getNext(new JobParameters());
        }
    }
    else {
        List<JobExecution> previousExecutions = this.jobExplorer
                .getJobExecutions(lastInstances.get(0));
        JobExecution previousExecution = previousExecutions.get(0);
        if (previousExecution == null) {
            // Normally this will not happen - an instance exists with no executions
            if (incrementer != null) {
                parameters = incrementer.getNext(new JobParameters());
            }
        }
        else if (isStoppedOrFailed(previousExecution) && job.isRestartable()) {
            // Retry a failed or stopped execution
            parameters = previousExecution.getJobParameters();
            // Non-identifying additional parameters can be removed to a retry
            removeNonIdentifying(additionals);
        }
        else if (incrementer != null) {
            // New instance so increment the parameters if we can
            parameters = incrementer.getNext(previousExecution.getJobParameters());
        }
    }
    return merge(parameters, additionals);
}
项目:spring-batch-tools    文件:BatchOperatorImpl.java   
private JobParameters getNextJobParameters(final String jobName) throws NoSuchJobException, JobParametersNotFoundException {
    final Job job = jobRegistry.getJob(jobName);
    final JobParametersIncrementer incrementer = Optional.ofNullable(job.getJobParametersIncrementer()).orElseThrow(
            () -> new JobParametersNotFoundException("No job parameters incrementer found for job " + jobName));

    return getNextJobParameters(jobName, incrementer);
}
项目:spring-batch-tools    文件:BatchOperatorImpl.java   
private JobParameters getNextJobParameters(final String jobName, final JobParametersIncrementer incrementer)
        throws JobParametersNotFoundException {
    final JobParameters previousParameters = jobExplorer.getJobInstances(jobName, 0, 1).stream().findFirst()
            .flatMap(instance -> jobExplorer.getJobExecutions(instance).stream().findFirst()).map(JobExecution::getJobParameters)
            .orElseGet(JobParameters::new);

    return Optional.ofNullable(incrementer.getNext(previousParameters)).orElseThrow(
            () -> new JobParametersNotFoundException("No bootstrap parameters found for job " + jobName));
}
项目:spring-batch-tools    文件:TestJobConfig.java   
@Bean
public Job testJob() {
    final JobParametersIncrementer incrementer = new RunIdIncrementer();

    return jobs.get(JOB_NAME) //
            .incrementer(incrementer) //
            .start(taskletStep()) //
            .next(chunkStep()) //
            .build();
}
项目:marklogic-spring-batch    文件:JobSupport.java   
@Override
public JobParametersIncrementer getJobParametersIncrementer() {
    return null;
}