List of usage examples for org.springframework.batch.core.launch JobParametersNotFoundException JobParametersNotFoundException
public JobParametersNotFoundException(String msg)
From source file:de.codecentric.batch.web.JobOperationsController.java
/** * Borrowed from CommandLineJobRunner./*from ww w .j ava2 s . com*/ * @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:egovframework.rte.bat.core.launch.support.EgovCommandLineRunner.java
/** * ? ? Batch Job? Job Parameter ?./* w w w.j a va 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:org.springframework.batch.core.launch.support.CommandLineJobRunner.java
/** * @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 *//*from w w w. ja v a2s . c o m*/ 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 { List<JobExecution> lastExecutions = jobExplorer.getJobExecutions(lastInstances.get(0)); jobParameters = incrementer.getNext(lastExecutions.get(0).getJobParameters()); } return jobParameters; }
From source file:org.springframework.batch.core.launch.support.SimpleJobOperator.java
@Override public Long startNextInstance(String jobName) throws NoSuchJobException, JobParametersNotFoundException, UnexpectedJobExecutionException, JobParametersInvalidException { logger.info("Locating parameters for next instance of job with name=" + jobName); Job job = jobRegistry.getJob(jobName); List<JobInstance> lastInstances = jobExplorer.getJobInstances(jobName, 0, 1); JobParametersIncrementer incrementer = job.getJobParametersIncrementer(); if (incrementer == null) { throw new JobParametersNotFoundException("No job parameters incrementer found for job=" + jobName); }/*from w ww .j a va2s . c o m*/ JobParameters parameters; if (lastInstances.isEmpty()) { parameters = incrementer.getNext(new JobParameters()); if (parameters == null) { throw new JobParametersNotFoundException("No bootstrap parameters found for job=" + jobName); } } else { List<JobExecution> lastExecutions = jobExplorer.getJobExecutions(lastInstances.get(0)); parameters = incrementer.getNext(lastExecutions.get(0).getJobParameters()); } logger.info(String.format("Attempting to launch job with name=%s and parameters=%s", jobName, parameters)); try { return jobLauncher.run(job, parameters).getId(); } catch (JobExecutionAlreadyRunningException e) { throw new UnexpectedJobExecutionException( String.format(ILLEGAL_STATE_MSG, "job already running", jobName, parameters), e); } catch (JobRestartException e) { throw new UnexpectedJobExecutionException( String.format(ILLEGAL_STATE_MSG, "job not restartable", jobName, parameters), e); } catch (JobInstanceAlreadyCompleteException e) { throw new UnexpectedJobExecutionException( String.format(ILLEGAL_STATE_MSG, "job instance already complete", jobName, parameters), e); } }
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//from w ww. ja va2s.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; }