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.
By default, the thread pool is synchronous.Constructor and Description |
---|
TaskExecutorPartitionHandler() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected FutureTask<StepExecution> |
createTask(Step step,
StepExecution stepExecution)
Creates the task executing the given step in the context of the given execution.
|
protected Set<StepExecution> |
doHandle(StepExecution masterStepExecution,
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, setGridSize
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
TaskExecutor
that is used to farm out step
executions to multiple threads.taskExecutor
- a TaskExecutor
public 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 StepHolder
StepHolder.getStep()
protected Set<StepExecution> doHandle(StepExecution masterStepExecution, Set<StepExecution> partitionStepExecutions) throws Exception
AbstractPartitionHandler
StepExecution
instances and returns an updated
view of them. Throws an Exception
if anything goes wrong.doHandle
in class AbstractPartitionHandler
masterStepExecution
- the whole partition executionpartitionStepExecutions
- the StepExecution
instances to executeStepExecution
instancesException
- 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 FutureTask<StepExecution> createTask(Step step, StepExecution stepExecution)
step
- the step to executestepExecution
- the given executionCopyright © 2014 Pivotal. All rights reserved.