List of usage examples for org.springframework.batch.core.repository JobExecutionAlreadyRunningException printStackTrace
public void printStackTrace()
From source file:com.spring.batch.BatchMain.java
public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-batch.xml"); JobParametersBuilder jobPara = new JobParametersBuilder(); // Job job = (Job) ctx.getBean("sampleFlow"); JobLauncher launcher = (JobLauncher) ctx.getBean("jobLauncher"); JobExecution result = null;/*w w w . j a va 2 s . c o m*/ try { result = launcher.run(job, jobPara.toJobParameters()); } catch (JobExecutionAlreadyRunningException e) { e.printStackTrace(); } catch (JobRestartException e) { e.printStackTrace(); } catch (JobInstanceAlreadyCompleteException e) { e.printStackTrace(); } catch (JobParametersInvalidException e) { e.printStackTrace(); } ExitStatus es = result.getExitStatus(); if (es.getExitCode().equals(ExitStatus.COMPLETED.getExitCode())) { System.out.println("finished"); } else { System.out.println("failed"); } }
From source file:com.japp.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments/*from www . j av a 2s . co m*/ */ public static void main(final String... args) { if (LOGGER.isInfoEnabled()) { LOGGER.info("\n=========================================================" + "\n " + "\n SFTP-File Transfer POC " + "\n " + "\n========================================================="); } final AbstractApplicationContext context = new ClassPathXmlApplicationContext( "classpath:/launch-context.xml"); context.registerShutdownHook(); SpringIntegrationUtils.displayDirectories(context); final Scanner scanner = new Scanner(System.in); JobLauncher jobLauncher = context.getBean("jobLauncher", JobLauncher.class); Job job = context.getBean("job1", Job.class); try { jobLauncher.run(job, new JobParameters()); } catch (JobExecutionAlreadyRunningException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (JobRestartException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (JobInstanceAlreadyCompleteException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (JobParametersInvalidException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } if (LOGGER.isInfoEnabled()) { LOGGER.info("\n=========================================================" + "\n " + "\n Please press 'q + Enter' to quit the application. " + "\n " + "\n========================================================="); } while (!scanner.hasNext("q")) { //Do nothing unless user presses 'q' to quit. } if (LOGGER.isInfoEnabled()) { LOGGER.info("Exiting application...bye."); } System.exit(0); }
From source file:com.dalamar.schedule.Scheduler.java
public void run() { try {//from w w w. j a v a 2 s .co m execution = launcher.run(job, new JobParameters()); System.out.println("Execution status: " + execution.getStatus()); } catch (JobExecutionAlreadyRunningException e) { e.printStackTrace(); } catch (JobRestartException e) { e.printStackTrace(); } catch (JobInstanceAlreadyCompleteException e) { e.printStackTrace(); } catch (JobParametersInvalidException e) { e.printStackTrace(); } }
From source file:org.springframework.yarn.batch.repository.JobRepositoryService.java
private BaseResponseObject handleCreateJobExecutionReq(CreateJobExecutionReq request) { CreateJobExecutionRes response = null; String jobName = request.jobName; Map<String, JobParameter> map = new HashMap<String, JobParameter>(); for (Entry<String, JobParameterType> entry : request.jobParameters.entrySet()) { ParameterType parameterType = entry.getValue().parameterType; if (parameterType == ParameterType.DATE) { if (entry.getValue().parameter instanceof Integer) { map.put(entry.getKey(), new JobParameter(new Date((Integer) entry.getValue().parameter))); } else if (entry.getValue().parameter instanceof Date) { map.put(entry.getKey(), new JobParameter(((Date) entry.getValue().parameter))); }//www .ja va 2 s .c om } else if (parameterType == ParameterType.DOUBLE) { map.put(entry.getKey(), new JobParameter((Double) entry.getValue().parameter)); } else if (parameterType == ParameterType.LONG) { if (entry.getValue().parameter instanceof Long) { map.put(entry.getKey(), new JobParameter((Long) entry.getValue().parameter)); } else if (entry.getValue().parameter instanceof Integer) { Long tmp = new Long((Integer) entry.getValue().parameter); map.put(entry.getKey(), new JobParameter(tmp)); } } else if (parameterType == ParameterType.STRING) { map.put(entry.getKey(), new JobParameter((String) entry.getValue().parameter)); } } JobParameters jobParameters = new JobParameters(map); //throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException JobExecution jobExecution = null; try { jobExecution = jobRepository.createJobExecution(jobName, jobParameters); } catch (JobExecutionAlreadyRunningException e) { e.printStackTrace(); } catch (JobRestartException e) { e.printStackTrace(); } catch (JobInstanceAlreadyCompleteException e) { e.printStackTrace(); } response = new CreateJobExecutionRes(); response.jobExecution = JobRepositoryRpcFactory.convertJobExecutionType(jobExecution); return response; }