Class PartitionStepBuilder
java.lang.Object
org.springframework.batch.core.step.builder.StepBuilderHelper<PartitionStepBuilder>
org.springframework.batch.core.step.builder.PartitionStepBuilder
- Direct Known Subclasses:
RemotePartitioningManagerStepBuilder
Step builder for
PartitionStep
instances. A partition step executes the same
step (possibly remotely) multiple times with different input parameters (in the form of
execution context). Useful for parallelization.- Since:
- 2.2
- Author:
- Dave Syer, Mahmoud Ben Hassine, Dimitrios Liapis
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper
StepBuilderHelper.CommonStepProperties
-
Field Summary
Fields inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper
logger, properties
-
Constructor Summary
ConstructorDescriptionPartitionStepBuilder
(StepBuilderHelper<?> parent) Create a new builder initialized with any properties in the parent. -
Method Summary
Modifier and TypeMethodDescriptionaggregator
(StepExecutionAggregator aggregator) Provide a step execution aggregator for aggregating partitioned step executions into a single result for thePartitionStep
itself.build()
protected StepExecutionAggregator
protected int
protected Partitioner
protected PartitionHandler
protected StepExecutionSplitter
protected Step
getStep()
protected String
protected org.springframework.core.task.TaskExecutor
gridSize
(int gridSize) A hint to thesplitter(StepExecutionSplitter)
about how many step executions are required.partitioner
(String workerStepName, Partitioner partitioner) Add a partitioner which can be used to create aStepExecutionSplitter
.partitionHandler
(PartitionHandler partitionHandler) Provide an explicit partition handler that will carry out the work of the partition step.protected PartitionStepBuilder
self()
splitter
(StepExecutionSplitter splitter) Provide an explicitStepExecutionSplitter
instead of having one build from thepartitioner(String, Partitioner)
.Provide an actual step instance to execute in parallel.taskExecutor
(org.springframework.core.task.TaskExecutor taskExecutor) Provide a task executor to use when constructing aPartitionHandler
from thestep(Step)
.Methods inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper
allowStartIfComplete, enhance, getJobRepository, getName, isAllowStartIfComplete, listener, listener, meterRegistry, observationConvention, observationRegistry, repository, startLimit
-
Constructor Details
-
PartitionStepBuilder
Create a new builder initialized with any properties in the parent. The parent is copied, so it can be re-used.- Parameters:
parent
- a parent helper containing common step properties
-
-
Method Details
-
partitioner
Add a partitioner which can be used to create aStepExecutionSplitter
. Use either this or an explicitsplitter(StepExecutionSplitter)
but not both.- Parameters:
workerStepName
- the name of the worker step (used to construct step execution names)partitioner
- a partitioner to use- Returns:
- this for fluent chaining
-
step
Provide an actual step instance to execute in parallel. If an explicitpartitionHandler(PartitionHandler)
is provided, the step is optional and is only used to extract configuration data (name and other basic properties of a step).- Parameters:
step
- a step to execute in parallel- Returns:
- this for fluent chaining
-
taskExecutor
Provide a task executor to use when constructing aPartitionHandler
from thestep(Step)
. Mainly used for running a step locally in parallel, but can be used to execute remotely if the step is remote. Not used if an explicitpartitionHandler(PartitionHandler)
is provided.- Parameters:
taskExecutor
- a task executor to use when executing steps in parallel- Returns:
- this for fluent chaining
-
partitionHandler
Provide an explicit partition handler that will carry out the work of the partition step. The partition handler is the main SPI for adapting a partition step to a specific distributed computation environment. Optional if you only need local or remote processing through the Step interface.- Parameters:
partitionHandler
- a partition handler- Returns:
- this for fluent chaining
- See Also:
-
gridSize
A hint to thesplitter(StepExecutionSplitter)
about how many step executions are required. If running locally or remotely through ataskExecutor(TaskExecutor)
determines precisely the number of step executions in the first attempt at a partition step execution.- Parameters:
gridSize
- the grid size- Returns:
- this for fluent chaining
-
splitter
Provide an explicitStepExecutionSplitter
instead of having one build from thepartitioner(String, Partitioner)
. Useful if you need more control over the splitting.- Parameters:
splitter
- a step execution splitter- Returns:
- this for fluent chaining
-
aggregator
Provide a step execution aggregator for aggregating partitioned step executions into a single result for thePartitionStep
itself. Default is a simple implementation that works in most cases.- Parameters:
aggregator
- a step execution aggregator- Returns:
- this for fluent chaining
-
build
-
self
- Specified by:
self
in classStepBuilderHelper<PartitionStepBuilder>
-
getTaskExecutor
protected org.springframework.core.task.TaskExecutor getTaskExecutor() -
getPartitioner
-
getStep
-
getPartitionHandler
-
getGridSize
protected int getGridSize() -
getSplitter
-
getAggregator
-
getStepName
-