Polish
This commit is contained in:
@@ -258,9 +258,9 @@ public class JsrPartitionHandler implements PartitionHandler, InitializingBean {
|
||||
|
||||
/**
|
||||
* Uses either the {@link PartitionMapper} or the hard coded configuration to split
|
||||
* the supplied master StepExecution into the slave StepExecutions.
|
||||
* the supplied manager StepExecution into the worker StepExecutions.
|
||||
*
|
||||
* @param stepExecution master {@link StepExecution}
|
||||
* @param stepExecution manager {@link StepExecution}
|
||||
* @param isRestart true if this step is being restarted
|
||||
* @return a {@link Set} of {@link StepExecution}s to be executed
|
||||
* @throws Exception
|
||||
|
||||
@@ -54,14 +54,14 @@ public class PartitionStep extends org.springframework.batch.core.partition.supp
|
||||
|
||||
/**
|
||||
* 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, summarizing 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)
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
|
||||
package org.springframework.batch.core.partition.support;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.Step;
|
||||
@@ -28,12 +34,6 @@ import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.core.task.TaskRejectedException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
/**
|
||||
* A {@link PartitionHandler} that uses a {@link TaskExecutor} to execute the
|
||||
* partitioned {@link Step} locally in multiple threads. This can be an
|
||||
@@ -90,7 +90,7 @@ public class TaskExecutorPartitionHandler extends AbstractPartitionHandler imple
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<StepExecution> doHandle(StepExecution masterStepExecution,
|
||||
protected Set<StepExecution> doHandle(StepExecution managerStepExecution,
|
||||
Set<StepExecution> partitionStepExecutions) throws Exception {
|
||||
Assert.notNull(step, "A Step must be provided.");
|
||||
final Set<Future<StepExecution>> tasks = new HashSet<>(getGridSize());
|
||||
|
||||
@@ -69,12 +69,12 @@ public class PartitionStepBuilder extends StepBuilderHelper<PartitionStepBuilder
|
||||
* Add a partitioner which can be used to create a {@link StepExecutionSplitter}. Use either this or an explicit
|
||||
* {@link #splitter(StepExecutionSplitter)} but not both.
|
||||
*
|
||||
* @param slaveStepName the name of the slave step (used to construct step execution names)
|
||||
* @param workerStepName the name of the worker step (used to construct step execution names)
|
||||
* @param partitioner a partitioner to use
|
||||
* @return this for fluent chaining
|
||||
*/
|
||||
public PartitionStepBuilder partitioner(String slaveStepName, Partitioner partitioner) {
|
||||
this.stepName = slaveStepName;
|
||||
public PartitionStepBuilder partitioner(String workerStepName, Partitioner partitioner) {
|
||||
this.stepName = workerStepName;
|
||||
this.partitioner = partitioner;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,15 @@
|
||||
*/
|
||||
package org.springframework.batch.core.partition.support;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -27,12 +34,6 @@ import org.springframework.batch.core.partition.StepExecutionSplitter;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
@@ -73,7 +74,7 @@ public class PartitionStepTests {
|
||||
StepExecution stepExecution = jobExecution.createStepExecution("foo");
|
||||
jobRepository.add(stepExecution);
|
||||
step.execute(stepExecution);
|
||||
// one master and two workers
|
||||
// one manager and two workers
|
||||
assertEquals(3, stepExecution.getJobExecution().getStepExecutions().size());
|
||||
assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
|
||||
}
|
||||
@@ -98,7 +99,7 @@ public class PartitionStepTests {
|
||||
StepExecution stepExecution = jobExecution.createStepExecution("foo");
|
||||
jobRepository.add(stepExecution);
|
||||
step.execute(stepExecution);
|
||||
// one master and two workers
|
||||
// one manager and two workers
|
||||
assertEquals(3, stepExecution.getJobExecution().getStepExecutions().size());
|
||||
assertEquals(BatchStatus.FAILED, stepExecution.getStatus());
|
||||
}
|
||||
@@ -146,7 +147,7 @@ public class PartitionStepTests {
|
||||
stepExecution = jobExecution.createStepExecution("foo");
|
||||
jobRepository.add(stepExecution);
|
||||
step.execute(stepExecution);
|
||||
// one master and two workers
|
||||
// one manager and two workers
|
||||
assertEquals(3, stepExecution.getJobExecution().getStepExecutions().size());
|
||||
assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
|
||||
}
|
||||
@@ -171,7 +172,7 @@ public class PartitionStepTests {
|
||||
StepExecution stepExecution = jobExecution.createStepExecution("foo");
|
||||
jobRepository.add(stepExecution);
|
||||
step.execute(stepExecution);
|
||||
// one master and two workers
|
||||
// one manager and two workers
|
||||
assertEquals(3, stepExecution.getJobExecution().getStepExecutions().size());
|
||||
assertEquals(BatchStatus.STOPPED, stepExecution.getStatus());
|
||||
}
|
||||
|
||||
@@ -942,7 +942,7 @@ Starting from version 4.1, Spring Batch Integration introduces the `@EnableBatch
|
||||
annotation that can be used to simplify a remote chunking setup. This annotation provides
|
||||
two beans that can be autowired in the application context:
|
||||
|
||||
* `RemoteChunkingMasterStepBuilderFactory`: used to configure the manager step
|
||||
* `RemoteChunkingManagerStepBuilderFactory`: used to configure the manager step
|
||||
* `RemoteChunkingWorkerBuilder`: used to configure the remote worker integration flow
|
||||
|
||||
These APIs take care of configuring a number of components as described in the following diagram:
|
||||
@@ -950,7 +950,7 @@ These APIs take care of configuring a number of components as described in the f
|
||||
.Remote Chunking Configuration
|
||||
image::{batch-asciidoc}images/remote-chunking-config.png[Remote Chunking Configuration, scaledwidth="80%"]
|
||||
|
||||
On the manager side, the `RemoteChunkingMasterStepBuilderFactory` lets you
|
||||
On the manager side, the `RemoteChunkingManagerStepBuilderFactory` lets you
|
||||
configure a manager step by declaring:
|
||||
|
||||
* the item reader to read items and send them to workers
|
||||
@@ -982,7 +982,7 @@ public class RemoteChunkingJobConfiguration {
|
||||
public static class ManagerConfiguration {
|
||||
|
||||
@Autowired
|
||||
private RemoteChunkingMasterStepBuilderFactory managerStepBuilderFactory;
|
||||
private RemoteChunkingManagerStepBuilderFactory managerStepBuilderFactory;
|
||||
|
||||
@Bean
|
||||
public TaskletStep managerStep() {
|
||||
@@ -1265,7 +1265,7 @@ link:$$https://github.com/spring-projects/spring-batch/tree/master/spring-batch-
|
||||
The `@EnableBatchIntegration` annotation that can be used to simplify a remote
|
||||
partitioning setup. This annotation provides two beans useful for remote partitioning:
|
||||
|
||||
* `RemotePartitioningMasterStepBuilderFactory`: used to configure the manager step
|
||||
* `RemotePartitioningManagerStepBuilderFactory`: used to configure the manager step
|
||||
* `RemotePartitioningWorkerStepBuilderFactory`: used to configure the worker step
|
||||
|
||||
These APIs take care of configuring a number of components as described in the following diagram:
|
||||
@@ -1276,7 +1276,7 @@ image::{batch-asciidoc}images/remote-partitioning-polling-config.png[Remote Part
|
||||
.Remote Partitioning Configuration (with replies aggregation)
|
||||
image::{batch-asciidoc}images/remote-partitioning-aggregation-config.png[Remote Partitioning Configuration (with replies aggregation), scaledwidth="80%"]
|
||||
|
||||
On the manager side, the `RemotePartitioningMasterStepBuilderFactory` allows you to
|
||||
On the manager side, the `RemotePartitioningManagerStepBuilderFactory` allows you to
|
||||
configure a manager step by declaring:
|
||||
|
||||
* the `Partitioner` used to partition data
|
||||
@@ -1308,7 +1308,7 @@ public class RemotePartitioningJobConfiguration {
|
||||
public static class ManagerConfiguration {
|
||||
|
||||
@Autowired
|
||||
private RemotePartitioningMasterStepBuilderFactory managerStepBuilderFactory;
|
||||
private RemotePartitioningManagerStepBuilderFactory managerStepBuilderFactory;
|
||||
|
||||
@Bean
|
||||
public Step managerStep() {
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package org.springframework.batch.repeat.support;
|
||||
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
|
||||
/**
|
||||
* Abstraction for queue of {@link ResultHolder} objects. Acts a bit likeT a
|
||||
* {@link BlockingQueue} with the ability to count the number of items it
|
||||
@@ -35,9 +35,9 @@ import java.util.concurrent.BlockingQueue;
|
||||
interface ResultQueue<T> {
|
||||
|
||||
/**
|
||||
* In a master-slave pattern, the master calls this method paired with
|
||||
* In a manager-worker pattern, the manager calls this method paired with
|
||||
* {@link #take()} to manage the flow of items. Normally a task is submitted
|
||||
* for processing in another thread, at which point the master uses this
|
||||
* for processing in another thread, at which point the manager uses this
|
||||
* method to keep track of the number of expected results. It has the
|
||||
* personality of an counter increment, rather than a work queue, which is
|
||||
* usually managed elsewhere, e.g. by a {@link TaskExecutor}.<br><br>
|
||||
@@ -50,7 +50,7 @@ interface ResultQueue<T> {
|
||||
|
||||
/**
|
||||
* Once it is expecting a result, clients call this method to satisfy the
|
||||
* expectation. In a master-worker pattern, the workers call this method to
|
||||
* expectation. In a manager-worker pattern, the workers call this method to
|
||||
* deposit the result of a finished task on the queue for collection.
|
||||
*
|
||||
* @param result the result for later collection.
|
||||
@@ -72,7 +72,7 @@ interface ResultQueue<T> {
|
||||
T take() throws NoSuchElementException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Used by master thread to verify that there are results available from
|
||||
* Used by manager thread to verify that there are results available from
|
||||
* {@link #take()} without possibly having to block and wait.
|
||||
*
|
||||
* @return true if there are no results available
|
||||
@@ -80,7 +80,7 @@ interface ResultQueue<T> {
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Check if any results are expected. Usually used by master thread to drain
|
||||
* Check if any results are expected. Usually used by manager thread to drain
|
||||
* queue when it is finished.
|
||||
*
|
||||
* @return true if more results are expected, but possibly not yet
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.batch.integration.chunk;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for a remote worker in the Remote Chunking pattern. A request comes from a master process containing some
|
||||
* Interface for a remote worker in the Remote Chunking pattern. A request comes from a manager process containing some
|
||||
* items to be processed. Once the items are done with a response needs to be generated containing a summary of the
|
||||
* result.
|
||||
*
|
||||
|
||||
@@ -40,8 +40,8 @@ import org.springframework.util.ReflectionUtils;
|
||||
* master. 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 master
|
||||
* and the slave listeners in the Remote Chunking pattern for the Step in question.
|
||||
* chunks are being sent to. Once this chunk handler is installed the application is playing the role of both the manager
|
||||
* and the worker listeners in the Remote Chunking pattern for the Step in question.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
|
||||
@@ -49,9 +49,9 @@ import org.springframework.util.CollectionUtils;
|
||||
* While a {@link org.springframework.messaging.MessageChannel} is used for sending the requests to the workers, the
|
||||
* worker's responses can be obtained in one of two ways:
|
||||
* <ul>
|
||||
* <li>A reply channel - Slaves will respond with messages that will be aggregated via this component.</li>
|
||||
* <li>Polling the job repository - Since the state of each slave is maintained independently within the job
|
||||
* repository, we can poll the store to determine the state without the need of the slaves to formally respond.</li>
|
||||
* <li>A reply channel - Workers will respond with messages that will be aggregated via this component.</li>
|
||||
* <li>Polling the job repository - Since the state of each worker is maintained independently within the job
|
||||
* repository, we can poll the store to determine the state without the need of the workers to formally respond.</li>
|
||||
* </ul>
|
||||
*
|
||||
* Note: The reply channel for this is instance based. Sharing this component across
|
||||
@@ -98,7 +98,7 @@ public class MessageChannelPartitionHandler implements PartitionHandler, Initial
|
||||
pollRepositoryForResults = !(dataSource == null && jobExplorer == null);
|
||||
|
||||
if(pollRepositoryForResults) {
|
||||
logger.debug("MessageChannelPartitionHandler is configured to poll the job repository for slave results");
|
||||
logger.debug("MessageChannelPartitionHandler is configured to poll the job repository for worker results");
|
||||
}
|
||||
|
||||
if(dataSource != null && jobExplorer == null) {
|
||||
@@ -134,7 +134,7 @@ public class MessageChannelPartitionHandler implements PartitionHandler, Initial
|
||||
}
|
||||
|
||||
/**
|
||||
* How often to poll the job repository for the status of the slaves.
|
||||
* How often to poll the job repository for the status of the workers.
|
||||
*
|
||||
* @param pollInterval milliseconds between polls, defaults to 10000 (10 seconds).
|
||||
*/
|
||||
|
||||
@@ -228,8 +228,8 @@ public class RemotePartitioningManagerStepBuilder extends PartitionStepBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemotePartitioningManagerStepBuilder partitioner(String slaveStepName, Partitioner partitioner) {
|
||||
super.partitioner(slaveStepName, partitioner);
|
||||
public RemotePartitioningManagerStepBuilder partitioner(String workerStepName, Partitioner partitioner) {
|
||||
super.partitioner(workerStepName, partitioner);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -645,13 +645,13 @@ not get shared across threads of execution.
|
||||
|
||||
### Remote Partitioning Sample
|
||||
|
||||
This sample shows how to configure a remote partitioning job. The master step
|
||||
This sample shows how to configure a remote partitioning job. The manager step
|
||||
uses a `MessageChannelPartitionHandler` to send partitions to and receive
|
||||
replies from workers. Two examples are shown:
|
||||
|
||||
* A master step that polls the job repository to see if all workers have finished
|
||||
* A manager step that polls the job repository to see if all workers have finished
|
||||
their work
|
||||
* A master step that aggregates replies from workers to notify work completion
|
||||
* A manager step that aggregates replies from workers to notify work completion
|
||||
|
||||
The sample uses an embedded JMS broker and an embedded database for simplicity
|
||||
but any option supported via Spring Integration for communication is technically
|
||||
@@ -659,18 +659,18 @@ acceptable.
|
||||
|
||||
### Remote Chunking Sample
|
||||
|
||||
This sample shows how to configure a remote chunking job. The master step will
|
||||
This sample shows how to configure a remote chunking job. The manager step will
|
||||
read numbers from 1 to 6 and send two chunks ({1, 2, 3} and {4, 5, 6}) to workers
|
||||
for processing and writing.
|
||||
|
||||
This example shows how to use:
|
||||
|
||||
* the `RemoteChunkingMasterStepBuilderFactory` to create a master step
|
||||
* the `RemoteChunkingManagerStepBuilderFactory` to create a manager step
|
||||
* the `RemoteChunkingWorkerBuilder` to configure an integration flow on the worker side.
|
||||
|
||||
The sample uses an embedded JMS broker as a communication middleware between the
|
||||
master and workers. The usage of an embedded broker is only for simplicity's sake,
|
||||
the communication between the master and workers is still done through JMS queues
|
||||
manager and workers. The usage of an embedded broker is only for simplicity's sake,
|
||||
the communication between the manager and workers is still done through JMS queues
|
||||
and Spring Integration channels and messages are sent over the wire through a TCP port.
|
||||
|
||||
### Quartz Sample
|
||||
|
||||
Reference in New Issue
Block a user