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-2007 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.
@@ -30,6 +30,7 @@ import org.springframework.batch.item.ExecutionContext;
* caller.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.0
*/
public interface PartitionHandler {
@@ -38,12 +39,12 @@ public interface PartitionHandler {
* Main entry point for {@link PartitionHandler} interface. The splitter
* creates all the executions that need to be farmed out, along with their
* input parameters (in the form of their {@link ExecutionContext}). The
* master step execution is used to identify the partition and group
* manager step execution is used to identify the partition and group
* together the results logically.
*
* @param stepSplitter a strategy for generating a collection of
* {@link StepExecution} instances
* @param stepExecution the master step execution for the whole partition
* @param stepExecution the manager step execution for the whole partition
* @return a collection of completed {@link StepExecution} instances
* @throws Exception if anything goes wrong. This allows implementations to
* be liberal and rely on the caller to translate an exception into a step

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2013 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.
@@ -31,6 +31,7 @@ import org.springframework.batch.core.partition.StepExecutionSplitter;
*
* @author Sebastien Gerard
* @author Dave Syer
* @author Mahmoud Ben Hassine
*/
public abstract class AbstractPartitionHandler implements PartitionHandler {
@@ -40,14 +41,14 @@ public abstract class AbstractPartitionHandler implements PartitionHandler {
* Executes the specified {@link StepExecution} instances and returns an updated
* view of them. Throws an {@link Exception} if anything goes wrong.
*
* @param masterStepExecution the whole partition execution
* @param managerStepExecution the whole partition execution
* @param partitionStepExecutions the {@link StepExecution} instances to execute
* @return an updated view of these completed {@link StepExecution} instances
* @throws Exception if anything goes wrong. This allows implementations to
* be liberal and rely on the caller to translate an exception into a step
* failure as necessary.
*/
protected abstract Set<StepExecution> doHandle(StepExecution masterStepExecution,
protected abstract Set<StepExecution> doHandle(StepExecution managerStepExecution,
Set<StepExecution> partitionStepExecutions) throws Exception;
/**
@@ -55,10 +56,10 @@ public abstract class AbstractPartitionHandler implements PartitionHandler {
*/
@Override
public Collection<StepExecution> handle(final StepExecutionSplitter stepSplitter,
final StepExecution masterStepExecution) throws Exception {
final Set<StepExecution> stepExecutions = stepSplitter.split(masterStepExecution, gridSize);
final StepExecution managerStepExecution) throws Exception {
final Set<StepExecution> stepExecutions = stepSplitter.split(managerStepExecution, gridSize);
return doHandle(masterStepExecution, stepExecutions);
return doHandle(managerStepExecution, stepExecutions);
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2013 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.
@@ -33,6 +33,7 @@ import java.util.Collection;
* load using a {@link PartitionHandler}.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.0
*/
public class PartitionStep extends AbstractStep {
@@ -87,14 +88,14 @@ public class PartitionStep extends AbstractStep {
/**
* Delegate execution to the {@link PartitionHandler} provided. The
* {@link StepExecution} passed in here becomes the parent or master
* {@link StepExecution} passed in here becomes the parent or manager
* execution for the partition, summarising the status on exit of the
* logical grouping of work carried out by the {@link PartitionHandler}. The
* individual step executions and their input parameters (through
* {@link ExecutionContext}) for the partition elements are provided by the
* {@link StepExecutionSplitter}.
*
* @param stepExecution the master step execution for the partition
* @param stepExecution the manager step execution for the partition
*
* @see Step#execute(StepExecution)
*/

View File

@@ -544,7 +544,7 @@
<xsd:attribute name="aggregator">
<xsd:annotation>
<xsd:documentation><![CDATA[
Reference to a StepExecutionAggregator that will be used to merge the partition results back into the master StepExecution]]>
Reference to a StepExecutionAggregator that will be used to merge the partition results back into the manager StepExecution]]>
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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,6 +37,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@ContextConfiguration(locations = "launch-context.xml")
@@ -74,7 +75,7 @@ public class RestartIntegrationTests {
ExampleItemReader.fail = true;
JobParameters jobParameters = new JobParametersBuilder().addString("restart", "yes").toJobParameters();
int beforeMaster = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME='step1:master'", Integer.class);
int beforeManager = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME='step1:manager'", Integer.class);
int beforePartition = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME like 'step1:partition%'", Integer.class);
ExampleItemWriter.clear();
@@ -88,11 +89,11 @@ public class RestartIntegrationTests {
// Only 4 because the others were processed in the first attempt
assertEquals(4, ExampleItemWriter.getItems().size());
int afterMaster = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME='step1:master'", Integer.class);
int afterManager = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME='step1:manager'", Integer.class);
int afterPartition = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME like 'step1:partition%'", Integer.class);
// Two attempts
assertEquals(2, afterMaster-beforeMaster);
assertEquals(2, afterManager-beforeManager);
// One failure and two successes
assertEquals(3, afterPartition-beforePartition);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 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.
@@ -32,6 +32,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
*/
@ContextConfiguration(locations="launch-context.xml")
@@ -58,12 +59,12 @@ public class VanillaIntegrationTests {
@Test
public void testLaunchJob() throws Exception {
int beforeMaster = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME='step1:master'", Integer.class);
int beforeManager = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME='step1:manager'", Integer.class);
int beforePartition = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME like 'step1:partition%'", Integer.class);
assertNotNull(jobLauncher.run(job, new JobParameters()));
int afterMaster = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME='step1:master'", Integer.class);
int afterManager = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME='step1:manager'", Integer.class);
int afterPartition = jdbcTemplate.queryForObject("SELECT COUNT(*) from BATCH_STEP_EXECUTION where STEP_NAME like 'step1:partition%'", Integer.class);
assertEquals(1, afterMaster-beforeMaster);
assertEquals(1, afterManager-beforeManager);
// Should be same as grid size in step splitter
assertEquals(2, afterPartition-beforePartition);
}

View File

@@ -11,7 +11,7 @@
<bean id="job1" parent="simpleJob">
<property name="steps">
<bean name="step1:master"
<bean name="step1:manager"
class="org.springframework.batch.core.partition.support.PartitionStep">
<property name="partitionHandler">
<bean