List of usage examples for org.springframework.batch.core.launch NoSuchJobException NoSuchJobException
public NoSuchJobException(String msg)
From source file:com.xchanging.support.batch.admin.service.SimpleJobService.java
/** * @param name//from w w w . j av a 2s. c om */ private void checkJobExists(String jobName) throws NoSuchJobException { if (jobLocator.getJobNames().contains(jobName)) { return; } if (jobInstanceDao.countJobInstances(jobName) > 0) { return; } throw new NoSuchJobException("No Job with that name either current or historic: [" + jobName + "]"); }
From source file:admin.service.SimpleJobService.java
private void checkJobExists(String jobName) throws NoSuchJobException { if (jobLocator.getJobNames().contains(jobName)) { return;/*from w w w . j a v a 2 s . c om*/ } if (jobInstanceDao.countJobInstances(jobName) > 0) { return; } throw new NoSuchJobException("No Job with that name either current or historic: [" + jobName + "]"); }
From source file:org.springframework.batch.core.launch.support.SimpleJobOperator.java
@Override public List<Long> getJobInstances(String jobName, int start, int count) throws NoSuchJobException { List<Long> list = new ArrayList<Long>(); List<JobInstance> jobInstances = jobExplorer.getJobInstances(jobName, start, count); for (JobInstance jobInstance : jobInstances) { list.add(jobInstance.getId());//from w ww . j av a 2s . c o m } if (list.isEmpty() && !jobRegistry.getJobNames().contains(jobName)) { throw new NoSuchJobException("No such job (either in registry or in historical data): " + jobName); } return list; }
From source file:org.springframework.batch.core.launch.support.SimpleJobOperator.java
@Override public Set<Long> getRunningExecutions(String jobName) throws NoSuchJobException { Set<Long> set = new LinkedHashSet<Long>(); for (JobExecution jobExecution : jobExplorer.findRunningJobExecutions(jobName)) { set.add(jobExecution.getId());// w w w . j av a 2s.c o m } if (set.isEmpty() && !jobRegistry.getJobNames().contains(jobName)) { throw new NoSuchJobException("No such job (either in registry or in historical data): " + jobName); } return set; }
From source file:org.springframework.cloud.dataflow.server.batch.SimpleJobService.java
@Override public JobExecution restart(Long jobExecutionId, JobParameters params) throws NoSuchJobExecutionException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, NoSuchJobException, JobParametersInvalidException { JobExecution jobExecution = null;//from w w w . j a va 2 s . c o m JobExecution target = getJobExecution(jobExecutionId); JobInstance lastInstance = target.getJobInstance(); if (jobLocator.getJobNames().contains(lastInstance.getJobName())) { Job job = jobLocator.getJob(lastInstance.getJobName()); jobExecution = jobLauncher.run(job, target.getJobParameters()); if (jobExecution.isRunning()) { activeExecutions.add(jobExecution); } } else { if (jsrJobOperator != null) { if (params != null) { jobExecution = new JobExecution(jsrJobOperator.restart(jobExecutionId, params.toProperties())); } else { jobExecution = new JobExecution(jsrJobOperator.restart(jobExecutionId, new Properties())); } } else { throw new NoSuchJobException( String.format("Can't find job associated with job execution id %s to restart", String.valueOf(jobExecutionId))); } } return jobExecution; }
From source file:org.springframework.cloud.dataflow.server.batch.SimpleJobService.java
@Override public JobExecution launch(String jobName, JobParameters jobParameters) throws NoSuchJobException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException { JobExecution jobExecution = null;// w ww .j av a 2 s . c o m if (jobLocator.getJobNames().contains(jobName)) { 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; } } if (job.getJobParametersIncrementer() != null && !restart) { jobParameters = job.getJobParametersIncrementer().getNext(jobParameters); } jobExecution = jobLauncher.run(job, jobParameters); if (jobExecution.isRunning()) { activeExecutions.add(jobExecution); } } else { if (jsrJobOperator != null) { jobExecution = new JobExecution(jsrJobOperator.start(jobName, jobParameters.toProperties())); } else { throw new NoSuchJobException( String.format("Unable to find job %s to launch", String.valueOf(jobName))); } } return jobExecution; }
From source file:org.springframework.cloud.dataflow.server.batch.SimpleJobService.java
private void checkJobExists(String jobName) throws NoSuchJobException { if (getJsrJobNames().contains(jobName)) { return;/*from w w w.j a v a 2s . c om*/ } if (jobLocator.getJobNames().contains(jobName)) { return; } if (jobInstanceDao.countJobInstances(jobName) > 0) { return; } throw new NoSuchJobException("No Job with that name either current or historic: [" + jobName + "]"); }
From source file:test.profile.ClassPathXmlJobRegistry.java
public void afterPropertiesSet() throws Exception { for (Resource resource : jobPaths) { ClassPathXmlApplicationContextFactory applicationContextFactory = new ClassPathXmlApplicationContextFactory(); applicationContextFactory.setPath(resource); applicationContextFactory.setApplicationContext(parent); ApplicationContext context = applicationContextFactory.createApplicationContext(); String[] names = context.getBeanNamesForType(Job.class); for (String name : names) { logger.debug("Registering job: " + name + " from context: " + resource); ApplicationContextJobFactory jobFactory = new ApplicationContextJobFactory( applicationContextFactory, name); jobRegistry.register(jobFactory); }/*from w w w . j a va2 s .c om*/ } if (jobRegistry.getJobNames().isEmpty()) { throw new NoSuchJobException("Could not locate any jobs in resources provided."); } }