public class JsrPartitionHandler extends java.lang.Object implements PartitionHandler, org.springframework.beans.factory.InitializingBean
ThreadPoolTaskExecutor
in
accordance with JSR-352. The results from each step is aggregated into a
cumulative result.Modifier and Type | Class and Description |
---|---|
static class |
JsrPartitionHandler.PartitionPlanState
Since a
PartitionPlan could provide dynamic data (different results from run to run),
the batch runtime needs to save off the results for restarts. |
Constructor and Description |
---|
JsrPartitionHandler() |
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.
|
java.util.Collection<java.lang.String> |
getPartitionStepNames() |
Step |
getStep() |
java.util.Collection<StepExecution> |
handle(StepExecutionSplitter stepSplitter,
StepExecution stepExecution)
Main entry point for
PartitionHandler interface. |
void |
setAllowStartIfComplete(boolean allowStartIfComplete) |
void |
setJobRepository(JobRepository jobRepository) |
void |
setPartitionAnalyzer(javax.batch.api.partition.PartitionAnalyzer analyzer) |
void |
setPartitionDataQueue(java.util.Queue<java.io.Serializable> queue) |
void |
setPartitionLock(java.util.concurrent.locks.ReentrantLock lock) |
void |
setPartitionMapper(javax.batch.api.partition.PartitionMapper mapper) |
void |
setPartitions(int partitions) |
void |
setPollingInterval(int pollingInterval) |
void |
setPropertyContext(BatchPropertyContext context) |
void |
setStep(Step step) |
void |
setThreads(int threads) |
public Step getStep()
public java.util.Collection<java.lang.String> getPartitionStepNames()
public void setAllowStartIfComplete(boolean allowStartIfComplete)
allowStartIfComplete
- flag stating if the step should restart if it
was complete in a previous runpublic void setPartitionDataQueue(java.util.Queue<java.io.Serializable> queue)
queue
- Queue
to receive the output of the PartitionCollector
public void setPartitionLock(java.util.concurrent.locks.ReentrantLock lock)
public void setPropertyContext(BatchPropertyContext context)
context
- BatchPropertyContext
to resolve partition level step propertiespublic void setPartitionMapper(javax.batch.api.partition.PartitionMapper mapper)
mapper
- PartitionMapper
used to configure partitioningpublic void setStep(Step step)
step
- the step to be executed as a partitioned steppublic void setPartitionAnalyzer(javax.batch.api.partition.PartitionAnalyzer analyzer)
analyzer
- PartitionAnalyzer
public void setThreads(int threads)
threads
- the number of threads to execute the partitions to be run
within. The default is the number of partitions.public void setPartitions(int partitions)
partitions
- the number of partitions to be executedpublic void setJobRepository(JobRepository jobRepository)
jobRepository
- JobRepository
public void setPollingInterval(int pollingInterval)
pollingInterval
- the duration of partitions completion polling interval
(in milliseconds). The default value is 500ms.public java.util.Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution) throws java.lang.Exception
PartitionHandler
PartitionHandler
interface. The splitter
creates all the executions that need to be farmed out, along with their
input parameters (in the form of their ExecutionContext
). The
master step execution is used to identify the partition and group
together the results logically.handle
in interface PartitionHandler
stepSplitter
- a strategy for generating a collection of
StepExecution
instancesstepExecution
- the master step execution for the whole partitionStepExecution
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 executionpublic void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception