List of usage examples for org.springframework.batch.core JobExecutionException JobExecutionException
public JobExecutionException(String msg)
From source file:es.fcs.batch.integration.chunk.SerializableChunkProcessor.java
@SuppressWarnings("unchecked") private void doInit() throws JobExecutionException { if (delegate != null) { // Delegate is already initialized return;// w w w. j av a 2s. c om } // Initializing processor and writer if (itemWriter == null && itemWriterSerializable == null) { throw new JobExecutionException("No itemWriter defined"); } if (itemProcessor == null && itemProcessorSerializable == null) { throw new JobExecutionException("No itemWriter defined"); } if (itemWriter == null) itemWriter = (ItemWriter) itemWriterSerializable; if (itemProcessor == null) itemProcessor = (ItemProcessor) itemProcessorSerializable; // Initializing delegate delegate = new SimpleChunkProcessor<I, O>(itemProcessor, itemWriter); }
From source file:org.springframework.yarn.batch.support.YarnJobLauncher.java
protected void executeJob(Job job, JobParameters jobParameters) throws JobExecutionException { String jobIdentifier = job.getName(); JobProperties jobProperties = yarnBatchProperties != null ? yarnBatchProperties.getJobProperties(jobIdentifier) : null;/*w w w .j a va 2 s .c o m*/ boolean restart = false; // re-create by adding props from a boot JobProperties if (jobProperties != null && jobProperties.getParameters() != null) { log.info("Job parameters from boot properties, parameters" + jobProperties.getParameters()); Properties tmpProperties = new Properties(); Map<String, Object> tmpParameters = jobProperties.getParameters(); tmpProperties.putAll(tmpParameters); JobParameters tmpJobParameters = this.converter.getJobParameters(tmpProperties); Map<String, JobParameter> map1 = new HashMap<String, JobParameter>(tmpJobParameters.getParameters()); map1.putAll(jobParameters.getParameters()); jobParameters = new JobParameters(map1); log.info("Modified jobParameters=" + jobParameters); } if (jobProperties != null && jobProperties.isRestart()) { if (jobExplorer == null) { throw new JobExecutionException( "A JobExplorer must be provided for a restart or start next operation."); } JobExecution jobExecution = getLastFailedJobExecution(jobIdentifier); if (log.isDebugEnabled()) { log.info("Last failed JobExecution: " + jobExecution); } if (jobExecution == null && jobProperties.isFailRestart()) { throw new JobExecutionNotFailedException( "No failed or stopped execution found for job=" + jobIdentifier); } else { log.info("No failed or stopped execution found for job=" + jobIdentifier + ", batch properties flag for failRestart=" + jobProperties.isFailRestart() + " so we don't fail restart."); } if (jobExecution != null) { restart = true; jobParameters = jobExecution.getJobParameters(); } } if (jobProperties != null && jobProperties.isNext() && !restart) { if (jobExplorer == null) { throw new JobExecutionException( "A JobExplorer must be provided for a restart or start next operation."); } JobParameters nextParameters = getNextJobParameters(job, false); Map<String, JobParameter> map = new HashMap<String, JobParameter>(nextParameters.getParameters()); map.putAll(jobParameters.getParameters()); jobParameters = new JobParameters(map); if (log.isDebugEnabled()) { log.info("JobParameter for job=[" + job + "] next=" + nextParameters + " used=" + jobParameters); } } JobExecution execution = this.jobLauncher.run(job, jobParameters); if (this.publisher != null) { this.publisher.publishEvent(new JobExecutionEvent(this, execution)); } }