Class AbstractPartitionHandler
java.lang.Object
org.springframework.batch.core.partition.support.AbstractPartitionHandler
- All Implemented Interfaces:
PartitionHandler
- Direct Known Subclasses:
MessageChannelPartitionHandler
,TaskExecutorPartitionHandler
Base
PartitionHandler
implementation providing common base features. Subclasses
are expected to implement only the
doHandle(org.springframework.batch.core.StepExecution, java.util.Set)
method
which returns with the result of the execution(s) or an exception if the step failed to
process.- Author:
- Sebastien Gerard, Dave Syer, Mahmoud Ben Hassine
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Set<StepExecution>
doHandle
(StepExecution managerStepExecution, Set<StepExecution> partitionStepExecutions) Executes the specifiedStepExecution
instances and returns an updated view of them.int
Returns the number of step executions.handle
(StepExecutionSplitter stepSplitter, StepExecution managerStepExecution) Main entry point forPartitionHandler
interface.void
setGridSize
(int gridSize) Passed to theStepExecutionSplitter
in thehandle(StepExecutionSplitter, StepExecution)
method, instructing it how manyStepExecution
instances are required, ideally.
-
Field Details
-
gridSize
protected int gridSize
-
-
Constructor Details
-
AbstractPartitionHandler
public AbstractPartitionHandler()
-
-
Method Details
-
doHandle
protected abstract Set<StepExecution> doHandle(StepExecution managerStepExecution, Set<StepExecution> partitionStepExecutions) throws Exception Executes the specifiedStepExecution
instances and returns an updated view of them. Throws anException
if anything goes wrong.- Parameters:
managerStepExecution
- the whole partition executionpartitionStepExecutions
- theStepExecution
instances to execute- Returns:
- an updated view of these completed
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.
-
handle
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution managerStepExecution) throws Exception Description copied from interface:PartitionHandler
Main entry point forPartitionHandler
interface. The splitter creates all the executions that need to be farmed out, along with their input parameters (in the form of theirExecutionContext
). The manager step execution is used to identify the partition and group together the results logically.- Specified by:
handle
in interfacePartitionHandler
- Parameters:
stepSplitter
- a strategy for generating a collection ofStepExecution
instancesmanagerStepExecution
- the manager step execution for the whole partition- Returns:
- a collection of completed
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.- See Also:
-
getGridSize
public int getGridSize()Returns the number of step executions.- Returns:
- the number of step executions
-
setGridSize
public void setGridSize(int gridSize) Passed to theStepExecutionSplitter
in thehandle(StepExecutionSplitter, StepExecution)
method, instructing it how manyStepExecution
instances are required, ideally. TheStepExecutionSplitter
is allowed to ignore the grid size in the case of a restart, since the input data partitions must be preserved.- Parameters:
gridSize
- the number of step executions that will be created
-