use of org.springframework.batch.core.JobParameters in project head by mifos.
the class MifosBatchJob method catchUpMissedLaunches.
public void catchUpMissedLaunches(Job job, JobExecutionContext context) throws Exception {
List<JobInstance> jobInstances = jobExplorer.getJobInstances(job.getName(), 0, 1);
if (jobInstances.size() > 0) {
JobInstance jobInstance = jobInstances.get(0);
Date previousFireTime = new Date(jobInstance.getJobParameters().getLong(JOB_EXECUTION_TIME_KEY));
Date scheduledFireTime = context.getScheduledFireTime();
Trigger trigger = context.getTrigger();
boolean onDemandRun = false;
if (Scheduler.DEFAULT_MANUAL_TRIGGERS.equals(trigger.getGroup())) {
// this is a manual run
trigger = context.getScheduler().getTrigger(job.getName(), Scheduler.DEFAULT_GROUP);
scheduledFireTime = new DateTimeService().getCurrentDateTime().toDate();
onDemandRun = true;
}
List<Date> missedLaunches = computeMissedJobLaunches(previousFireTime, scheduledFireTime, trigger, onDemandRun);
for (Date missedLaunch : missedLaunches) {
JobParameters jobParameters = createJobParameters(missedLaunch.getTime());
launchJob(job, jobParameters);
}
}
}
use of org.springframework.batch.core.JobParameters in project pinpoint by naver.
the class BatchJobLauncher method alarmJob.
public void alarmJob() {
JobParameters params = createTimeParameter();
run("alarmJob", params);
}
use of org.springframework.batch.core.JobParameters in project spring-boot by spring-projects.
the class JobLauncherCommandLineRunnerTests method retryFailedExecution.
@Test
public void retryFailedExecution() throws Exception {
this.job = this.jobs.get("job").start(this.steps.get("step").tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
throw new RuntimeException("Planned");
}
}).build()).incrementer(new RunIdIncrementer()).build();
this.runner.execute(this.job, new JobParameters());
this.runner.execute(this.job, new JobParameters());
assertThat(this.jobExplorer.getJobInstances("job", 0, 100)).hasSize(1);
}
use of org.springframework.batch.core.JobParameters in project spring-boot by spring-projects.
the class JobLauncherCommandLineRunnerTests method basicExecution.
@Test
public void basicExecution() throws Exception {
this.runner.execute(this.job, new JobParameters());
assertThat(this.jobExplorer.getJobInstances("job", 0, 100)).hasSize(1);
this.runner.execute(this.job, new JobParametersBuilder().addLong("id", 1L).toJobParameters());
assertThat(this.jobExplorer.getJobInstances("job", 0, 100)).hasSize(2);
}
use of org.springframework.batch.core.JobParameters in project spring-boot by spring-projects.
the class JobLauncherCommandLineRunnerTests method incrementExistingExecution.
@Test
public void incrementExistingExecution() throws Exception {
this.job = this.jobs.get("job").start(this.step).incrementer(new RunIdIncrementer()).build();
this.runner.execute(this.job, new JobParameters());
this.runner.execute(this.job, new JobParameters());
assertThat(this.jobExplorer.getJobInstances("job", 0, 100)).hasSize(2);
}
Aggregations