step.setPartitionHandler(partitionHandler); step.setPartitionHandler(partitionHandler);
@Test public void testVanillaStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { @Override public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set<StepExecution> executions = stepSplitter.split(stepExecution, 2); for (StepExecution execution : executions) { execution.setStatus(BatchStatus.COMPLETED); execution.setExitStatus(ExitStatus.COMPLETED); } return executions; } }); step.afterPropertiesSet(); JobExecution jobExecution = jobRepository.createJobExecution("vanillaJob", new JobParameters()); StepExecution stepExecution = jobExecution.createStepExecution("foo"); jobRepository.add(stepExecution); step.execute(stepExecution); // one master and two workers assertEquals(3, stepExecution.getJobExecution().getStepExecutions().size()); assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus()); }
@Test public void testFailedStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { @Override public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set<StepExecution> executions = stepSplitter.split(stepExecution, 2); for (StepExecution execution : executions) { execution.setStatus(BatchStatus.FAILED); execution.setExitStatus(ExitStatus.FAILED); } return executions; } }); step.afterPropertiesSet(); JobExecution jobExecution = jobRepository.createJobExecution("vanillaJob", new JobParameters()); StepExecution stepExecution = jobExecution.createStepExecution("foo"); jobRepository.add(stepExecution); step.execute(stepExecution); // one master and two workers assertEquals(3, stepExecution.getJobExecution().getStepExecutions().size()); assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); }
@Test public void testStoppedStepExecution() throws Exception { step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { @Override public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { Set<StepExecution> executions = stepSplitter.split(stepExecution, 2); for (StepExecution execution : executions) { execution.setStatus(BatchStatus.STOPPED); execution.setExitStatus(ExitStatus.STOPPED); } return executions; } }); step.afterPropertiesSet(); JobExecution jobExecution = jobRepository.createJobExecution("vanillaJob", new JobParameters()); StepExecution stepExecution = jobExecution.createStepExecution("foo"); jobRepository.add(stepExecution); step.execute(stepExecution); // one master and two workers assertEquals(3, stepExecution.getJobExecution().getStepExecutions().size()); assertEquals(BatchStatus.STOPPED, stepExecution.getStatus()); }
final AtomicBoolean started = new AtomicBoolean(false); step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { @Override public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
@Test public void testStepAggregator() throws Exception { step.setStepExecutionAggregator(new DefaultStepExecutionAggregator() { @Override public void aggregate(StepExecution result, Collection<StepExecution> executions) { super.aggregate(result, executions); result.getExecutionContext().put("aggregated", true); } }); step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner())); step.setPartitionHandler(new PartitionHandler() { @Override public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws Exception { return Arrays.asList(stepExecution); } }); step.afterPropertiesSet(); JobExecution jobExecution = jobRepository.createJobExecution("vanillaJob", new JobParameters()); StepExecution stepExecution = jobExecution.createStepExecution("foo"); jobRepository.add(stepExecution); step.execute(stepExecution); assertEquals(true, stepExecution.getExecutionContext().get("aggregated")); }
private void configurePartitionStep(PartitionStep ts) { Assert.state(partitioner != null, "A Partitioner must be provided for a partition step"); Assert.state(step != null, "A Step must be provided for a partition step"); configureAbstractStep(ts); if (partitionHandler != null) { ts.setPartitionHandler(partitionHandler); } else { TaskExecutorPartitionHandler partitionHandler = new TaskExecutorPartitionHandler(); partitionHandler.setStep(step); if (taskExecutor == null) { taskExecutor = new SyncTaskExecutor(); } partitionHandler.setGridSize(gridSize); partitionHandler.setTaskExecutor(taskExecutor); ts.setPartitionHandler(partitionHandler); } SimpleStepExecutionSplitter splitter = new SimpleStepExecutionSplitter(jobRepository, step, partitioner); ts.setStepExecutionSplitter(splitter); }
step.setPartitionHandler(partitionHandler); step.setPartitionHandler(partitionHandler);
step.setPartitionHandler(partitionHandler); step.setPartitionHandler(partitionHandler);
step.setPartitionHandler(partitionHandler); step.setPartitionHandler(partitionHandler);