use of org.springframework.batch.core.JobParameter in project pinpoint by naver.
the class AlarmJobTest method getParameters.
private static JobParameters getParameters() {
Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
parameters.put("schedule.scheduledFireTime", new JobParameter(new Date()));
return new JobParameters(parameters);
}
use of org.springframework.batch.core.JobParameter in project spring-boot by spring-projects.
the class JobLauncherCommandLineRunner method getNextJobParameters.
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);
}
use of org.springframework.batch.core.JobParameter in project spring-boot by spring-projects.
the class JobLauncherCommandLineRunner method merge.
private JobParameters merge(JobParameters parameters, Map<String, JobParameter> additionals) {
Map<String, JobParameter> merged = new HashMap<>();
merged.putAll(parameters.getParameters());
merged.putAll(additionals);
parameters = new JobParameters(merged);
return parameters;
}
Aggregations