/** * Creates a {@link RemotePartitioningMasterStepBuilder} and initializes its job * repository, job explorer, bean factory and transaction manager. * @param name the name of the step * @return a {@link RemotePartitioningMasterStepBuilder} */ public RemotePartitioningMasterStepBuilder get(String name) { return new RemotePartitioningMasterStepBuilder(name) .repository(this.jobRepository) .jobExplorer(this.jobExplorer) .beanFactory(this.beanFactory) .transactionManager(this.transactionManager); }
@Bean public Step masterStep() { return this.masterStepBuilderFactory.get("masterStep") .partitioner("workerStep", new BasicPartitioner()) .gridSize(GRID_SIZE) .outputChannel(requests()) .build(); }
Step step = new RemotePartitioningMasterStepBuilder("masterStep") .repository(jobRepository) .outputChannel(outputChannel) .partitioner("workerStep", partitioner) .gridSize(gridSize) .pollInterval(pollInterval) .timeout(timeout) .startLimit(startLimit) .aggregator(stepExecutionAggregator) .allowStartIfComplete(true) .build();
@Test public void eitherOutputChannelOrMessagingTemplateMustBeProvided() { // given RemotePartitioningMasterStepBuilder builder = new RemotePartitioningMasterStepBuilder("step") .outputChannel(new DirectChannel()) .messagingTemplate(new MessagingTemplate()); this.expectedException.expect(IllegalStateException.class); this.expectedException.expectMessage("You must specify either an outputChannel or a messagingTemplate but not both."); // when Step step = builder.build(); // then // expected exception }
@Test public void jobExplorerMustNotBeNull() { // given this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("jobExplorer must not be null"); // when new RemotePartitioningMasterStepBuilder("step").jobExplorer(null); // then // expected exception }
@Test public void inputChannelMustNotBeNull() { // given this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("inputChannel must not be null"); // when new RemotePartitioningMasterStepBuilder("step").inputChannel(null); // then // expected exception }
@Test public void outputChannelMustNotBeNull() { // given this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("outputChannel must not be null"); // when new RemotePartitioningMasterStepBuilder("step").outputChannel(null); // then // expected exception }
@Test public void pollIntervalMustBeGreaterThanZero() { // given this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("The poll interval must be greater than zero"); // when new RemotePartitioningMasterStepBuilder("step").pollInterval(-1); // then // expected exception }
@Test public void messagingTemplateMustNotBeNull() { // given this.expectedException.expect(IllegalArgumentException.class); this.expectedException.expectMessage("messagingTemplate must not be null"); // when new RemotePartitioningMasterStepBuilder("step").messagingTemplate(null); // then // expected exception }
@Test public void testUnsupportedOperationExceptionWhenSpecifyingPartitionHandler() { // given PartitionHandler partitionHandler = Mockito.mock(PartitionHandler.class); this.expectedException.expect(UnsupportedOperationException.class); this.expectedException.expectMessage("When configuring a master step " + "for remote partitioning using the RemotePartitioningMasterStepBuilder, " + "the partition handler will be automatically set to an instance " + "of MessageChannelPartitionHandler. The partition handler must " + "not be provided in this case."); // when new RemotePartitioningMasterStepBuilder("step").partitionHandler(partitionHandler); // then // expected exception }
Step step = new RemotePartitioningMasterStepBuilder("masterStep") .repository(jobRepository) .outputChannel(outputChannel) .partitioner("workerStep", partitioner) .gridSize(gridSize) .startLimit(startLimit) .aggregator(stepExecutionAggregator) .allowStartIfComplete(true) .build();
@Bean public Step masterStep() { return this.masterStepBuilderFactory.get("masterStep") .partitioner("workerStep", new BasicPartitioner()) .gridSize(GRID_SIZE) .outputChannel(requests()) .inputChannel(replies()) .build(); }