Remove usage of master/slave terminology

This commit is contained in:
Mahmoud Ben Hassine
2021-08-17 21:59:30 +02:00
parent 24152e7a57
commit 36b63ed283
33 changed files with 120 additions and 99 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2018 the original author or authors.
* Copyright 2006-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ import org.springframework.util.ReflectionUtils;
/**
* Convenient factory bean for a chunk handler that also converts an existing chunk-oriented step into a remote chunk
* master. The idea is to lift the existing chunk processor out of a Step that works locally, and replace it with a one
* manager. The idea is to lift the existing chunk processor out of a Step that works locally, and replace it with a one
* that writes chunks into a message channel. The existing step hands its business chunk processing responsibility over
* to the handler produced by the factory, which then needs to be set up as a worker on the other end of the channel the
* chunks are being sent to. Once this chunk handler is installed the application is playing the role of both the manager
@@ -58,7 +58,7 @@ public class RemoteChunkHandlerFactoryBean<T> implements FactoryBean<ChunkHandle
private StepContributionSource stepContributionSource;
/**
* The local step that is to be converted to a remote chunk master.
* The local step that is to be converted to a remote chunk manager.
*
* @param step the step to set
*/
@@ -161,7 +161,7 @@ public class RemoteChunkHandlerFactoryBean<T> implements FactoryBean<ChunkHandle
}
/**
* Replace the chunk processor in the tasklet provided with one that can act as a master in the Remote Chunking
* Replace the chunk processor in the tasklet provided with one that can act as a manager in the Remote Chunking
* pattern.
*
* @param tasklet a ChunkOrientedTasklet

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018 the original author or authors.
* Copyright 2018-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ public class RemoteChunkingWorkerBuilder<I, O> {
private MessageChannel outputChannel;
/**
* Set the {@link ItemProcessor} to use to process items sent by the master
* Set the {@link ItemProcessor} to use to process items sent by the manager
* step.
*
* @param itemProcessor to use
@@ -66,7 +66,7 @@ public class RemoteChunkingWorkerBuilder<I, O> {
}
/**
* Set the {@link ItemWriter} to use to write items sent by the master step.
* Set the {@link ItemWriter} to use to write items sent by the manager step.
*
* @param itemWriter to use
* @return this builder instance for fluent chaining
@@ -78,7 +78,7 @@ public class RemoteChunkingWorkerBuilder<I, O> {
}
/**
* Set the input channel on which items sent by the master are received.
* Set the input channel on which items sent by the manager are received.
*
* @param inputChannel the input channel
* @return this builder instance for fluent chaining
@@ -90,7 +90,7 @@ public class RemoteChunkingWorkerBuilder<I, O> {
}
/**
* Set the output channel on which replies will be sent to the master step.
* Set the output channel on which replies will be sent to the manager step.
*
* @param outputChannel the output channel
* @return this builder instance for fluent chaining

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2009-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.integration.partition;
import java.util.ArrayList;
@@ -209,9 +224,9 @@ public class MessageChannelPartitionHandler implements PartitionHandler, Initial
* @see PartitionHandler#handle(StepExecutionSplitter, StepExecution)
*/
public Collection<StepExecution> handle(StepExecutionSplitter stepExecutionSplitter,
final StepExecution masterStepExecution) throws Exception {
final StepExecution managerStepExecution) throws Exception {
final Set<StepExecution> split = stepExecutionSplitter.split(masterStepExecution, gridSize);
final Set<StepExecution> split = stepExecutionSplitter.split(managerStepExecution, gridSize);
if(CollectionUtils.isEmpty(split)) {
return split;
@@ -232,11 +247,11 @@ public class MessageChannelPartitionHandler implements PartitionHandler, Initial
return receiveReplies(replyChannel);
}
else {
return pollReplies(masterStepExecution, split);
return pollReplies(managerStepExecution, split);
}
}
private Collection<StepExecution> pollReplies(final StepExecution masterStepExecution, final Set<StepExecution> split) throws Exception {
private Collection<StepExecution> pollReplies(final StepExecution managerStepExecution, final Set<StepExecution> split) throws Exception {
final Collection<StepExecution> result = new ArrayList<>(split.size());
Callable<Collection<StepExecution>> callback = new Callable<Collection<StepExecution>>() {
@@ -248,7 +263,7 @@ public class MessageChannelPartitionHandler implements PartitionHandler, Initial
if(!result.contains(curStepExecution)) {
StepExecution partitionStepExecution =
jobExplorer.getStepExecution(masterStepExecution.getJobExecutionId(), curStepExecution.getId());
jobExplorer.getStepExecution(managerStepExecution.getJobExecutionId(), curStepExecution.getId());
if(!partitionStepExecution.getStatus().isRunning()) {
result.add(partitionStepExecution);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018 the original author or authors.
* Copyright 2018-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,15 +50,15 @@ import org.springframework.util.Assert;
* creates an {@link IntegrationFlow} that:
*
* <ul>
* <li>listens to {@link StepExecutionRequest}s coming from the master
* <li>listens to {@link StepExecutionRequest}s coming from the manager
* on the input channel</li>
* <li>invokes the {@link StepExecutionRequestHandler} to execute the worker
* step for each incoming request. The worker step is located using the provided
* {@link StepLocator}. If no {@link StepLocator} is provided, a {@link BeanFactoryStepLocator}
* configured with the current {@link BeanFactory} will be used
* <li>replies to the master on the output channel (when the master step is
* <li>replies to the manager on the output channel (when the manager step is
* configured to aggregate replies from workers). If no output channel
* is provided, a {@link NullChannel} will be used (assuming the master side
* is provided, a {@link NullChannel} will be used (assuming the manager side
* is configured to poll the job repository for workers status)</li>
* </ul>
*
@@ -85,7 +85,7 @@ public class RemotePartitioningWorkerStepBuilder extends StepBuilder {
}
/**
* Set the input channel on which step execution requests sent by the master
* Set the input channel on which step execution requests sent by the manager
* are received.
* @param inputChannel the input channel
* @return this builder instance for fluent chaining
@@ -97,7 +97,7 @@ public class RemotePartitioningWorkerStepBuilder extends StepBuilder {
}
/**
* Set the output channel on which replies will be sent to the master step.
* Set the output channel on which replies will be sent to the manager step.
* @param outputChannel the input channel
* @return this builder instance for fluent chaining
*/
@@ -235,7 +235,7 @@ public class RemotePartitioningWorkerStepBuilder extends StepBuilder {
if (this.outputChannel == null) {
if (logger.isDebugEnabled()) {
logger.debug("The output channel is set to a NullChannel. " +
"The master step must poll the job repository for workers status.");
"The manager step must poll the job repository for workers status.");
}
this.outputChannel = new NullChannel();
}

View File

@@ -48,6 +48,7 @@ import static org.mockito.Mockito.when;
*
* @author Will Schipp
* @author Michael Minella
* @author Mahmoud Ben Hassine
*
*/
public class MessageChannelPartitionHandlerTests {
@@ -59,11 +60,11 @@ public class MessageChannelPartitionHandlerTests {
//execute with no default set
messageChannelPartitionHandler = new MessageChannelPartitionHandler();
//mock
StepExecution masterStepExecution = mock(StepExecution.class);
StepExecution managerStepExecution = mock(StepExecution.class);
StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
//execute
Collection<StepExecution> executions = messageChannelPartitionHandler.handle(stepExecutionSplitter, masterStepExecution);
Collection<StepExecution> executions = messageChannelPartitionHandler.handle(stepExecutionSplitter, managerStepExecution);
//verify
assertTrue(executions.isEmpty());
}
@@ -74,7 +75,7 @@ public class MessageChannelPartitionHandlerTests {
//execute with no default set
messageChannelPartitionHandler = new MessageChannelPartitionHandler();
//mock
StepExecution masterStepExecution = mock(StepExecution.class);
StepExecution managerStepExecution = mock(StepExecution.class);
StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
MessagingTemplate operations = mock(MessagingTemplate.class);
Message message = mock(Message.class);
@@ -88,7 +89,7 @@ public class MessageChannelPartitionHandlerTests {
messageChannelPartitionHandler.setMessagingOperations(operations);
//execute
Collection<StepExecution> executions = messageChannelPartitionHandler.handle(stepExecutionSplitter, masterStepExecution);
Collection<StepExecution> executions = messageChannelPartitionHandler.handle(stepExecutionSplitter, managerStepExecution);
//verify
assertNotNull(executions);
assertTrue(executions.isEmpty());
@@ -100,7 +101,7 @@ public class MessageChannelPartitionHandlerTests {
//execute with no default set
messageChannelPartitionHandler = new MessageChannelPartitionHandler();
//mock
StepExecution masterStepExecution = mock(StepExecution.class);
StepExecution managerStepExecution = mock(StepExecution.class);
StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
MessagingTemplate operations = mock(MessagingTemplate.class);
Message message = mock(Message.class);
@@ -116,7 +117,7 @@ public class MessageChannelPartitionHandlerTests {
messageChannelPartitionHandler.setReplyChannel(replyChannel);
//execute
Collection<StepExecution> executions = messageChannelPartitionHandler.handle(stepExecutionSplitter, masterStepExecution);
Collection<StepExecution> executions = messageChannelPartitionHandler.handle(stepExecutionSplitter, managerStepExecution);
//verify
assertNotNull(executions);
assertTrue(executions.isEmpty());
@@ -129,7 +130,7 @@ public class MessageChannelPartitionHandlerTests {
//execute with no default set
messageChannelPartitionHandler = new MessageChannelPartitionHandler();
//mock
StepExecution masterStepExecution = mock(StepExecution.class);
StepExecution managerStepExecution = mock(StepExecution.class);
StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
MessagingTemplate operations = mock(MessagingTemplate.class);
Message message = mock(Message.class);
@@ -142,7 +143,7 @@ public class MessageChannelPartitionHandlerTests {
messageChannelPartitionHandler.setMessagingOperations(operations);
//execute
messageChannelPartitionHandler.handle(stepExecutionSplitter, masterStepExecution);
messageChannelPartitionHandler.handle(stepExecutionSplitter, managerStepExecution);
}
@Test
@@ -151,7 +152,7 @@ public class MessageChannelPartitionHandlerTests {
messageChannelPartitionHandler = new MessageChannelPartitionHandler();
//mock
JobExecution jobExecution = new JobExecution(5L, new JobParameters());
StepExecution masterStepExecution = new StepExecution("step1", jobExecution, 1L);
StepExecution managerStepExecution = new StepExecution("step1", jobExecution, 1L);
StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
MessagingTemplate operations = mock(MessagingTemplate.class);
JobExplorer jobExplorer = mock(JobExplorer.class);
@@ -179,7 +180,7 @@ public class MessageChannelPartitionHandlerTests {
messageChannelPartitionHandler.afterPropertiesSet();
//execute
Collection<StepExecution> executions = messageChannelPartitionHandler.handle(stepExecutionSplitter, masterStepExecution);
Collection<StepExecution> executions = messageChannelPartitionHandler.handle(stepExecutionSplitter, managerStepExecution);
//verify
assertNotNull(executions);
assertEquals(3, executions.size());
@@ -197,7 +198,7 @@ public class MessageChannelPartitionHandlerTests {
messageChannelPartitionHandler = new MessageChannelPartitionHandler();
//mock
JobExecution jobExecution = new JobExecution(5L, new JobParameters());
StepExecution masterStepExecution = new StepExecution("step1", jobExecution, 1L);
StepExecution managerStepExecution = new StepExecution("step1", jobExecution, 1L);
StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
MessagingTemplate operations = mock(MessagingTemplate.class);
JobExplorer jobExplorer = mock(JobExplorer.class);
@@ -223,6 +224,6 @@ public class MessageChannelPartitionHandlerTests {
messageChannelPartitionHandler.afterPropertiesSet();
//execute
messageChannelPartitionHandler.handle(stepExecutionSplitter, masterStepExecution);
messageChannelPartitionHandler.handle(stepExecutionSplitter, managerStepExecution);
}
}

View File

@@ -46,8 +46,8 @@ import static org.springframework.test.util.ReflectionTestUtils.getField;
* @author Mahmoud Ben Hassine
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = {RemotePartitioningMasterStepBuilderTests.BatchConfiguration.class})
public class RemotePartitioningMasterStepBuilderTests {
@ContextConfiguration(classes = {RemotePartitioningManagerStepBuilderTests.BatchConfiguration.class})
public class RemotePartitioningManagerStepBuilderTests {
@Autowired
private JobRepository jobRepository;
@@ -151,7 +151,7 @@ public class RemotePartitioningMasterStepBuilderTests {
}
@Test
public void testMasterStepCreationWhenPollingRepository() {
public void testManagerStepCreationWhenPollingRepository() {
// given
int gridSize = 5;
int startLimit = 3;
@@ -162,7 +162,7 @@ public class RemotePartitioningMasterStepBuilderTests {
StepExecutionAggregator stepExecutionAggregator = (result, executions) -> { };
// when
Step step = new RemotePartitioningManagerStepBuilder("masterStep")
Step step = new RemotePartitioningManagerStepBuilder("managerStep")
.repository(jobRepository)
.outputChannel(outputChannel)
.partitioner("workerStep", partitioner)
@@ -196,7 +196,7 @@ public class RemotePartitioningMasterStepBuilderTests {
}
@Test
public void testMasterStepCreationWhenAggregatingReplies() {
public void testManagerStepCreationWhenAggregatingReplies() {
// given
int gridSize = 5;
int startLimit = 3;
@@ -205,7 +205,7 @@ public class RemotePartitioningMasterStepBuilderTests {
StepExecutionAggregator stepExecutionAggregator = (result, executions) -> { };
// when
Step step = new RemotePartitioningManagerStepBuilder("masterStep")
Step step = new RemotePartitioningManagerStepBuilder("managerStep")
.repository(jobRepository)
.outputChannel(outputChannel)
.partitioner("workerStep", partitioner)

View File

@@ -6,7 +6,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration
https://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd">
https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<batch-int:remote-chunking-master message-template="messagingTemplate" step="process" reply-channel="replies"/>
<batch-int:remote-chunking-manager message-template="messagingTemplate" step="process" reply-channel="replies"/>
</beans>

View File

@@ -6,7 +6,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration
https://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd">
https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<batch-int:remote-chunking-master id="itemWriter" step="process" reply-channel="replies"/>
<batch-int:remote-chunking-manager id="itemWriter" step="process" reply-channel="replies"/>
</beans>

View File

@@ -6,7 +6,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration
https://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd">
https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<batch-int:remote-chunking-master id="itemWriter" message-template="messagingTemplate" step="process"/>
<batch-int:remote-chunking-manager id="itemWriter" message-template="messagingTemplate" step="process"/>
</beans>

View File

@@ -6,7 +6,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration
https://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd">
https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<batch-int:remote-chunking-master id="itemWriter" message-template="messagingTemplate" reply-channel="replies"/>
<batch-int:remote-chunking-manager id="itemWriter" message-template="messagingTemplate" reply-channel="replies"/>
</beans>

View File

@@ -11,7 +11,7 @@
http://www.springframework.org/schema/batch
https://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/batch-integration
https://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd
https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd">
<batch:job id="processingJob">
@@ -37,7 +37,7 @@
</constructor-arg>
</bean>
<batch-int:remote-chunking-master id="itemWriter" message-template="messagingTemplate" step="process" reply-channel="replies"/>
<batch-int:remote-chunking-manager id="itemWriter" message-template="messagingTemplate" step="process" reply-channel="replies"/>
<bean id="messagingTemplate" class="org.springframework.integration.core.MessagingTemplate"/>

View File

@@ -6,8 +6,8 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration
https://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd">
https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<batch-int:remote-chunking-slave input-channel="requests" output-channel="replies"
<batch-int:remote-chunking-worker input-channel="requests" output-channel="replies"
item-processor="itemProcessor" item-writer="itemWriter"/>
</beans>

View File

@@ -6,8 +6,8 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration
https://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd">
https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<batch-int:remote-chunking-slave id="remote-chunking-slave" output-channel="replies"
<batch-int:remote-chunking-worker id="remote-chunking-worker" output-channel="replies"
item-processor="itemProcessor" item-writer="itemWriter"/>
</beans>

View File

@@ -6,8 +6,8 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration
https://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd">
https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<batch-int:remote-chunking-slave id="remote-chunking-slave" input-channel="requests" output-channel="replies"
<batch-int:remote-chunking-worker id="remote-chunking-worker" input-channel="requests" output-channel="replies"
item-processor="itemProcessor"/>
</beans>

View File

@@ -6,8 +6,8 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration
https://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd">
https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<batch-int:remote-chunking-slave id="remote-chunking-slave" input-channel="requests"
<batch-int:remote-chunking-worker id="remote-chunking-worker" input-channel="requests"
item-processor="itemProcessor" item-writer="itemWriter"/>
</beans>

View File

@@ -7,9 +7,9 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration
https://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd">
https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<batch-int:remote-chunking-slave id="remote-chunking-slave" input-channel="requests" output-channel="replies"
<batch-int:remote-chunking-worker id="remote-chunking-worker" input-channel="requests" output-channel="replies"
item-writer="itemWriter"/>
<bean id="itemProcessor" class="org.springframework.batch.integration.config.xml.RemoteChunkingParserTests$Processor"/>

View File

@@ -7,9 +7,9 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration
https://www.springframework.org/schema/batch-integration/spring-batch-integration-3.1.xsd">
https://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<batch-int:remote-chunking-slave id="remote-chunking-slave" input-channel="requests" output-channel="replies"
<batch-int:remote-chunking-worker id="remote-chunking-worker" input-channel="requests" output-channel="replies"
item-processor="itemProcessor" item-writer="itemWriter"/>
<bean id="itemProcessor" class="org.springframework.batch.integration.config.xml.RemoteChunkingParserTests$Processor"/>

View File

@@ -54,7 +54,7 @@
</bean>
<job id="job1" xmlns="http://www.springframework.org/schema/batch">
<step id="step1-master">
<step id="step1-manager">
<partition handler="partitionHandler" partitioner="partitioner" />
</step>
</job>

View File

@@ -35,7 +35,7 @@
</bean>
<job id="job1" xmlns="http://www.springframework.org/schema/batch">
<step id="step1-master">
<step id="step1-manager">
<partition handler="partitionHandler" partitioner="partitioner" />
</step>
</job>

View File

@@ -43,7 +43,7 @@
</bean>
<job id="job1" xmlns="http://www.springframework.org/schema/batch">
<step id="step1-master">
<step id="step1-manager">
<partition handler="partitionHandler" partitioner="partitioner" />
</step>
</job>