本文整理汇总了Java中org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException类的典型用法代码示例。如果您正苦于以下问题:Java JobInstanceAlreadyCompleteException类的具体用法?Java JobInstanceAlreadyCompleteException怎么用?Java JobInstanceAlreadyCompleteException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JobInstanceAlreadyCompleteException类属于org.springframework.batch.core.repository包,在下文中一共展示了JobInstanceAlreadyCompleteException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateGenericArchive
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
@Test
public void testCreateGenericArchive() throws NoSuchJobException,
JobExecutionAlreadyRunningException, JobRestartException,
JobInstanceAlreadyCompleteException, JobParametersInvalidException, IOException {
Map<String, JobParameter> parameters =
new HashMap<String, JobParameter>();
JobParameters jobParameters = new JobParameters(parameters);
Job palmwebArchive = jobLocator.getJob("PalmWeb");
assertNotNull("Palmweb must not be null", palmwebArchive);
JobExecution jobExecution = jobLauncher.run(palmwebArchive, jobParameters);
assertEquals("The job should complete successfully",jobExecution.getExitStatus().getExitCode(),"COMPLETED");
for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
logger.info(stepExecution.getStepName() + " "
+ stepExecution.getReadCount() + " "
+ stepExecution.getFilterCount() + " "
+ stepExecution.getWriteCount() + " " + stepExecution.getCommitCount());
}
}
示例2: start
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
public void start() throws IOException, InterruptedException {
List<JobExecution> jobExecutions = new ArrayList<>();
// launch jobs
jobExecutions.addAll(IntStream.range(0, this.cardinality).mapToObj(i -> {
Job analysisJob = this.jobFactory.get();
JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
jobParametersBuilder.addString("id", analysisJob.getName() + "-" + i, true);
try {
return this.jobLauncher.run(analysisJob, jobParametersBuilder.toJobParameters());
} catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException
| JobParametersInvalidException exception) {
throw new RuntimeException(exception);
}
}).collect(Collectors.toList()));
// wait for termination
while (jobExecutions.stream().anyMatch(jobExecution -> jobExecution.getStatus().isRunning())) {
Thread.sleep(1000);
}
}
示例3: launch
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
@RequestMapping("/launch")
public String launch() throws JobExecutionAlreadyRunningException,
JobRestartException, JobInstanceAlreadyCompleteException,
JobParametersInvalidException {
//JobParametersの内容を変更しないと同一のジョブ実行と思われるっぽい。
//同一のジョブ実行だと思われたら二回目からは実行されない。
//(一回目の実行が既に完了しているので)
//とりあえずIDっぽいものを持たせて実行の要求の度にインクリメントすることで
//何度も実行できるようになった。
//cf. JobParametersIncrementer
JobParameters jobParameters = new JobParametersBuilder().addLong(
"simpleBatchId", idGenerator.getAndIncrement())
.toJobParameters();
JobExecution execution = launcher.run(job, jobParameters);
return execution.toString();
}
示例4: launch
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
@Override
public void launch(JobLaunchRequest request) {
Job job;
try {
job = jobLocator.getJob(request.getJob());
Map<String, JobParameter> jobParameterMap = new HashMap<String, JobParameter>();
for(String parameterName : request.getParameters().keySet()) {
jobParameterMap.put(parameterName, new JobParameter(request.getParameters().get(parameterName)));
}
JobParameters jobParameters = new JobParameters(jobParameterMap);
try {
jobLauncher.run(job, jobParameters);
} catch (JobExecutionAlreadyRunningException jeare) {
jobStatusNotifier.notify(new JobExecutionException(jeare.getLocalizedMessage()), request.getParameters().get("resource.identifier"));
} catch (JobRestartException jre) {
jobStatusNotifier.notify(new JobExecutionException(jre.getLocalizedMessage()), request.getParameters().get("resource.identifier"));
} catch (JobInstanceAlreadyCompleteException jiace) {
jobStatusNotifier.notify(new JobExecutionException(jiace.getLocalizedMessage()), request.getParameters().get("resource.identifier"));
} catch (JobParametersInvalidException jpie) {
jobStatusNotifier.notify(new JobExecutionException(jpie.getLocalizedMessage()), request.getParameters().get("resource.identifier"));
}
} catch (NoSuchJobException nsje) {
jobStatusNotifier.notify(new JobExecutionException(nsje.getLocalizedMessage()), request.getParameters().get("resource.identifier"));
}
}
示例5: testNotModifiedResponse
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
/**
*
* @throws IOException
* if a temporary file cannot be created.
* @throws NoSuchJobException
* if SpeciesPageHarvestingJob cannot be located
* @throws JobParametersInvalidException
* if the job parameters are invalid
* @throws JobInstanceAlreadyCompleteException
* if the job has already completed
* @throws JobRestartException
* if the job cannot be restarted
* @throws JobExecutionAlreadyRunningException
* if the job is already running
*/
@Test
public final void testNotModifiedResponse() throws IOException,
NoSuchJobException, JobExecutionAlreadyRunningException,
JobRestartException, JobInstanceAlreadyCompleteException,
JobParametersInvalidException {
Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
parameters.put("query.string", new JobParameter("select i from Image i"));
JobParameters jobParameters = new JobParameters(parameters);
Job job = jobLocator.getJob("ImageProcessing");
assertNotNull("ImageProcessing must not be null", job);
JobExecution jobExecution = jobLauncher.run(job, jobParameters);
assertEquals("The job should complete successfully",jobExecution.getExitStatus().getExitCode(),"COMPLETED");
for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
logger.info(stepExecution.getStepName() + " "
+ stepExecution.getReadCount() + " "
+ stepExecution.getFilterCount() + " "
+ stepExecution.getWriteCount());
}
}
示例6: launch
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
@Override
public void launch(JobLaunchRequest request) {
Job job;
try {
job = jobLocator.getJob(request.getJob());
Map<String, JobParameter> jobParameterMap = new HashMap<String, JobParameter>();
for(String parameterName : request.getParameters().keySet()) {
jobParameterMap.put(parameterName, new JobParameter(request.getParameters().get(parameterName)));
}
JobParameters jobParameters = new JobParameters(jobParameterMap);
jobLauncher.run(job, jobParameters);
} catch (NoSuchJobException
| JobExecutionAlreadyRunningException
| JobRestartException
| JobInstanceAlreadyCompleteException
| JobParametersInvalidException exception) {
jobStatusNotifier.notify(new JobExecutionException(exception.getLocalizedMessage()), request.getParameters().get("job.configuration.id"));
}
}
示例7: launchImmediately
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
private JobExecution launchImmediately(TaskExecutor taskExecutor, Job job, JobParameters jobParameters)
{
try
{
SimpleJobLauncher launcher = new SimpleJobLauncher();
launcher.setJobRepository(jobRepository);
launcher.setTaskExecutor(taskExecutor);
return launcher.run(job, jobParameters);
}
catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException
| JobParametersInvalidException e)
{
logger.error("Unexpected exception", e);
throw YonaException.unexpected(e);
}
}
示例8: whitelist
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
public static String whitelist(Exception exception) {
if (exception instanceof JobInstanceAlreadyCompleteException) {
return "Job instance already complete exception";
} else if (exception instanceof JsonProcessingException) {
return "Json processing exception";
} else if (exception instanceof IOException) {
return "IO exception";
} else if (exception instanceof TransactionException) {
return "Transaction exception";
} else if (exception instanceof DataAccessException) {
return "Data access exception";
} else if (exception instanceof SQLException) {
return "SQL exception";
}
return exception.getMessage();
}
示例9: main
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
public static void main(String[] args) throws JobExecutionAlreadyRunningException, JobRestartException,
JobInstanceAlreadyCompleteException, JobParametersInvalidException, DuplicateJobException {
ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);
Job simpleJob = ctx.getBean("simpleJob", Job.class);
JobRegistry jobRegistry = ctx.getBean("jobRegistry", JobRegistry.class);
jobRegistry.register(new ReferenceJobFactory(simpleJob));
//JobRepository jobRepository = ctx.getBean("jobRepository", JobRepository.class);
//JobInstance jobInstance = jobRepository.createJobInstance("simpleJob", new JobParameters());
// JobParameters jobParameters = ctx.getBean("basicParameters", JobParameters.class);
//
//JobRegistry jobRegistry = ctx.getBean("mapJobRegistry", JobRegistry.class);
// jobRegistry.register();
// jobLauncher.run(job, jobParameters);
}
示例10: restartable
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
@Test
public void restartable() throws Exception {
when(taskletForRestartableJob.execute(any(StepContribution.class), any(ChunkContext.class)))
.thenThrow(new RuntimeException())
.thenReturn(RepeatStatus.FINISHED);
JobParameters jobParameters =
new JobParametersBuilder().addLong("date", System.currentTimeMillis()).toJobParameters();
JobExecution exec = jobLauncher.run(restartableJob, jobParameters);
assertThat(exec.getStatus()).isEqualTo(BatchStatus.FAILED);
exec = jobLauncher.run(restartableJob, jobParameters);
assertThat(exec.getStatus()).isEqualTo(BatchStatus.COMPLETED);
try {
exec = jobLauncher.run(restartableJob, jobParameters);
Assert.fail("job 인스턴스는 이미 완료되었습니다. 완료된 놈을 실행시키면 JobInstanceAlreadyCompleteException이 발생해야 합니다.");
} catch (JobInstanceAlreadyCompleteException e) {
// OK
}
}
示例11: execute
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
protected void execute(Job job, JobParameters jobParameters)
throws JobExecutionAlreadyRunningException, JobRestartException,
JobInstanceAlreadyCompleteException, JobParametersInvalidException,
JobParametersNotFoundException {
JobParameters nextParameters = getNextJobParameters(job, jobParameters);
if (nextParameters != null) {
JobExecution execution = this.jobLauncher.run(job, nextParameters);
if (this.publisher != null) {
this.publisher.publishEvent(new JobExecutionEvent(execution));
}
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:JobLauncherCommandLineRunner.java
示例12: run
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
/**
* Runs the scheduled job.
*
* @throws JobParametersInvalidException
* @throws JobInstanceAlreadyCompleteException
* @throws JobRestartException
* @throws JobExecutionAlreadyRunningException
*/
@Scheduled(fixedRate = RATE)
public void run() throws JobExecutionAlreadyRunningException,
JobRestartException, JobInstanceAlreadyCompleteException,
JobParametersInvalidException {
JobParameters params = new JobParameters(new HashMap<String, JobParameter>() {
private static final long serialVersionUID = 1L;
{
put("execDate", new JobParameter(new Date(), true));
}
});
jobLauncher.run(job, params);
}
示例13: shouldTaskletWork
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
@Test
public void shouldTaskletWork() throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException,
JobParametersInvalidException {
Map<String, JobParameter> params = Maps.newHashMap();
params.put("test", new JobParameter("przodownik"));
params.put("time", new JobParameter(new Date()));
JobExecution execution = jobLauncher.run(simpleStringProcessorTask, new JobParameters(params));
log.info("Exit Status : {}", execution.getExitStatus());
Assert.assertEquals(ExitStatus.COMPLETED, execution.getExitStatus());
}
示例14: requestJob3
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
@RequestMapping("/job3/{input_file_name}")
@ResponseBody
String requestJob3(@PathVariable("input_file_name") String inputFileName) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException{
JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
jobParametersBuilder.addString("INPUT_FILE_PATH", inputFileName);
jobParametersBuilder.addLong("TIMESTAMP",new Date().getTime());
jobLauncher.run(job3, jobParametersBuilder.toJobParameters());
return "Job3!";
}
开发者ID:pauldeng,项目名称:aws-elastic-beanstalk-worker-spring-boot-spring-batch-template,代码行数:11,代码来源:RESTController.java
示例15: testMatchTaxa
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; //导入依赖的package包/类
/**
*
* @throws IOException
* if a temporary file cannot be created.
* @throws NoSuchJobException
* if SpeciesPageHarvestingJob cannot be located
* @throws JobParametersInvalidException
* if the job parameters are invalid
* @throws JobInstanceAlreadyCompleteException
* if the job has already completed
* @throws JobRestartException
* if the job cannot be restarted
* @throws JobExecutionAlreadyRunningException
* if the job is already running
*/
@Test
public final void testMatchTaxa() throws IOException,
NoSuchJobException, JobExecutionAlreadyRunningException,
JobRestartException, JobInstanceAlreadyCompleteException,
JobParametersInvalidException {
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
List<Taxon> taxa = session.createQuery("from Taxon as taxon").list();
solrIndexingListener.indexObjects(taxa);
tx.commit();
ClassPathResource input = new ClassPathResource("/org/emonocot/job/taxonmatch/input.csv");
Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
parameters.put("assume.accepted.matches", new JobParameter(Boolean.TRUE.toString()));
parameters.put("input.file", new JobParameter(input.getFile().getAbsolutePath()));
parameters.put("output.file", new JobParameter(File.createTempFile("output", "csv").getAbsolutePath()));
JobParameters jobParameters = new JobParameters(parameters);
Job taxonMatchingJob = jobLocator.getJob("TaxonMatching");
assertNotNull("TaxonMatching must not be null", taxonMatchingJob);
JobExecution jobExecution = jobLauncher.run(taxonMatchingJob, jobParameters);
assertEquals("The job should complete successfully",jobExecution.getExitStatus().getExitCode(),"COMPLETED");
FileReader file = new FileReader(jobParameters.getParameters().get("output.file").getValue().toString());
BufferedReader reader = new BufferedReader(file);
assertNotNull("There should be an output file", reader);
String ln;
while ((ln = reader.readLine()) != null) {
logger.debug(ln);
}
}