List of usage examples for org.springframework.batch.core Job getJobParametersIncrementer
@Nullable JobParametersIncrementer getJobParametersIncrementer();
From source file:org.obiba.onyx.core.batch.OnyxJobDetailDelegate.java
@SuppressWarnings("unchecked") protected void executeInternal(JobExecutionContext context) { Map<String, Object> jobDataMap = context.getMergedJobDataMap(); String jobName = (String) jobDataMap.get(JOB_NAME); log.info("Quartz trigger firing with Spring Batch jobName=" + jobName); try {//ww w . ja v a 2 s. c om Job job = jobLocator.getJob(jobName); if (job.getJobParametersIncrementer() != null) { jobOperator.startNextInstance(jobName); } else { JobParameters jobParameters = getJobParametersFromJobMap(jobDataMap); jobOperator.start(jobName, toKeyValueCommaDelimitedString(jobParameters)); } } catch (Exception e) { log.error("Could not execute job.", e); } }
From source file:org.appverse.web.framework.backend.batch.services.business.impl.live.JobRunnerServiceImpl.java
@Override public JobExecution runJob(Job job) throws Exception { return jobLauncher.run(job, job.getJobParametersIncrementer().getNext(new JobParameters())); }
From source file:org.appverse.web.framework.backend.batch.services.business.impl.live.JobRunnerServiceImpl.java
@Override public JobExecution runJob(String jobName) throws Exception { Job job = jobRegistry.getJob(jobName); return jobLauncher.run(job, job.getJobParametersIncrementer().getNext(new JobParameters())); }
From source file:org.appverse.web.framework.backend.batch.services.business.impl.live.JobRunnerServiceImpl.java
@Override public JobExecution runJob(String jobName, int postExecutionSleepTime) throws Exception { if (skipExecution(jobName, postExecutionSleepTime)) { return null; }//from ww w . j av a 2 s.c o m Job job = jobRegistry.getJob(jobName); return jobLauncher.run(job, job.getJobParametersIncrementer().getNext(new JobParameters())); }
From source file:org.appverse.web.framework.backend.batch.services.business.impl.live.JobRunnerServiceImpl.java
@Override public JobExecution runJob(Job job, int postExecutionSleepTime) throws Exception { if (skipExecution(job.getName(), postExecutionSleepTime)) { return null; }/*from ww w .jav a2 s. co m*/ return jobLauncher.run(job, job.getJobParametersIncrementer().getNext(new JobParameters())); }
From source file:de.codecentric.batch.web.JobOperationsController.java
/** * Borrowed from CommandLineJobRunner.//from w ww .j a v a 2 s. c om * @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; }
From source file:fr.acxio.tools.agia.common.JobLauncherDetails.java
@SuppressWarnings("unchecked") protected void executeInternal(JobExecutionContext context) { Map<String, Object> jobDataMap = context.getMergedJobDataMap(); String jobName = (String) jobDataMap.get(JOB_NAME); LOGGER.info("Quartz trigger firing with Spring Batch jobName=" + jobName); try {/*w w w . jav a 2s. com*/ Job job = jobLocator.getJob(jobName); JobParameters previousJobParameters = null; List<JobInstance> jobInstances = jobExplorer.getJobInstances(jobName, 0, 1); if ((jobInstances != null) && (jobInstances.size() > 0)) { previousJobParameters = jobInstances.get(0).getJobParameters(); } JobParameters jobParameters = getJobParametersFromJobMap(jobDataMap, previousJobParameters); if (job.getJobParametersIncrementer() != null) { jobParameters = job.getJobParametersIncrementer().getNext(jobParameters); } jobLauncher.run(jobLocator.getJob(jobName), jobParameters); } catch (JobExecutionException e) { LOGGER.error("Could not execute job.", e); } }
From source file:de.codecentric.batch.web.JobOperationsController.java
private JobParameters createJobParametersWithIncrementerIfAvailable(String parameters, Job job) throws JobParametersNotFoundException { JobParameters jobParameters = jobParametersConverter .getJobParameters(PropertiesConverter.stringToProperties(parameters)); // use JobParametersIncrementer to create JobParameters if incrementer is set and only if the job is no restart if (job.getJobParametersIncrementer() != null) { JobExecution lastJobExecution = jobRepository.getLastJobExecution(job.getName(), jobParameters); boolean restart = false; // check if job failed before if (lastJobExecution != null) { BatchStatus status = lastJobExecution.getStatus(); if (status.isUnsuccessful() && status != BatchStatus.ABANDONED) { restart = true;//from w w w . ja v a 2 s. c o m } } // if it's not a restart, create new JobParameters with the incrementer if (!restart) { JobParameters nextParameters = getNextJobParameters(job); Map<String, JobParameter> map = new HashMap<String, JobParameter>(nextParameters.getParameters()); map.putAll(jobParameters.getParameters()); jobParameters = new JobParameters(map); } } return jobParameters; }
From source file:egovframework.rte.bat.core.launch.support.EgovCommandLineRunner.java
/** * ? ? Batch Job? Job Parameter ?./*from w w w . j a v a 2 s.c o m*/ * * @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; }
From source file:com.xchanging.support.batch.admin.service.SimpleJobService.java
public JobExecution launch(String jobName, JobParameters jobParameters) throws NoSuchJobException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException { Job job = jobLocator.getJob(jobName); JobExecution lastJobExecution = jobRepository.getLastJobExecution(jobName, jobParameters); boolean restart = false; if (lastJobExecution != null) { BatchStatus status = lastJobExecution.getStatus(); if (status.isUnsuccessful() && status != BatchStatus.ABANDONED) { restart = true;//from w ww. j a va2 s. c o m } } if (job.getJobParametersIncrementer() != null && !restart) { jobParameters = job.getJobParametersIncrementer().getNext(jobParameters); } JobExecution jobExecution = jobLauncher.run(job, jobParameters); if (jobExecution.isRunning()) { activeExecutions.add(jobExecution); } return jobExecution; }