public class TaskExecutorPartitionHandler extends AbstractPartitionHandler implements StepHolder, org.springframework.beans.factory.InitializingBean
PartitionHandler that uses a TaskExecutor to execute the
partitioned Step locally in multiple threads. This can be an
effective approach for scaling batch steps that are IO intensive, like
directory and filesystem scanning and copying.
| Constructor and Description |
|---|
TaskExecutorPartitionHandler() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected java.util.concurrent.FutureTask<StepExecution> |
createTask(Step step,
StepExecution stepExecution)
Creates the task executing the given step in the context of the given execution.
|
protected java.util.Set<StepExecution> |
doHandle(StepExecution masterStepExecution,
java.util.Set<StepExecution> partitionStepExecutions)
Executes the specified
StepExecution instances and returns an updated
view of them. |
Step |
getStep()
The step instance that will be executed in parallel by this handler.
|
void |
setStep(Step step)
Setter for the
Step that will be used to execute the partitioned
StepExecution. |
void |
setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
Setter for the
TaskExecutor that is used to farm out step
executions to multiple threads. |
getGridSize, handle, setGridSizepublic void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionpublic void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
TaskExecutor that is used to farm out step
executions to multiple threads.taskExecutor - a TaskExecutorpublic void setStep(Step step)
Step that will be used to execute the partitioned
StepExecution. This is a regular Spring Batch step, with all the
business logic required to complete an execution based on the input
parameters in its StepExecution context.step - the Step instance to use to execute business logicpublic Step getStep()
getStep in interface StepHolderStepHolder.getStep()protected java.util.Set<StepExecution> doHandle(StepExecution masterStepExecution, java.util.Set<StepExecution> partitionStepExecutions) throws java.lang.Exception
AbstractPartitionHandlerStepExecution instances and returns an updated
view of them. Throws an Exception if anything goes wrong.doHandle in class AbstractPartitionHandlermasterStepExecution - the whole partition executionpartitionStepExecutions - the StepExecution instances to executeStepExecution instancesjava.lang.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 java.util.concurrent.FutureTask<StepExecution> createTask(Step step, StepExecution stepExecution)
step - the step to executestepExecution - the given execution