Class JsrPartitionHandler

  • All Implemented Interfaces:
    PartitionHandler, org.springframework.beans.factory.InitializingBean

    public class JsrPartitionHandler
    extends java.lang.Object
    implements PartitionHandler, org.springframework.beans.factory.InitializingBean
    Executes a step instance per thread using a ThreadPoolTaskExecutor in accordance with JSR-352. The results from each step is aggregated into a cumulative result.
    Since:
    3.0
    Author:
    Michael Minella, Mahmoud Ben Hassine
    • Constructor Detail

      • JsrPartitionHandler

        public JsrPartitionHandler()
    • Method Detail

      • getStep

        public Step getStep()
        Returns:
        the step that will be executed by each partition
      • getPartitionStepNames

        public java.util.Collection<java.lang.String> getPartitionStepNames()
        Returns:
        the names of each partitioned step
      • setAllowStartIfComplete

        public void setAllowStartIfComplete​(boolean allowStartIfComplete)
        Parameters:
        allowStartIfComplete - flag stating if the step should restart if it was complete in a previous run
      • setPartitionDataQueue

        public void setPartitionDataQueue​(java.util.Queue<java.io.Serializable> queue)
        Parameters:
        queue - Queue to receive the output of the PartitionCollector
      • setPartitionLock

        public void setPartitionLock​(java.util.concurrent.locks.ReentrantLock lock)
      • setPartitionMapper

        public void setPartitionMapper​(javax.batch.api.partition.PartitionMapper mapper)
        Parameters:
        mapper - PartitionMapper used to configure partitioning
      • setStep

        public void setStep​(Step step)
        Parameters:
        step - the step to be executed as a partitioned step
      • setPartitionAnalyzer

        public void setPartitionAnalyzer​(javax.batch.api.partition.PartitionAnalyzer analyzer)
        Parameters:
        analyzer - PartitionAnalyzer
      • setThreads

        public void setThreads​(int threads)
        Parameters:
        threads - the number of threads to execute the partitions to be run within. The default is the number of partitions.
      • setPartitions

        public void setPartitions​(int partitions)
        Parameters:
        partitions - the number of partitions to be executed
      • setPollingInterval

        public void setPollingInterval​(int pollingInterval)
        Parameters:
        pollingInterval - the duration of partitions completion polling interval (in milliseconds). The default value is 500ms.
      • handle

        public java.util.Collection<StepExecution> handle​(StepExecutionSplitter stepSplitter,
                                                          StepExecution stepExecution)
                                                   throws java.lang.Exception
        Description copied from interface: PartitionHandler
        Main entry point for 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.
        Specified by:
        handle in interface PartitionHandler
        Parameters:
        stepSplitter - a strategy for generating a collection of StepExecution instances
        stepExecution - the master step execution for the whole partition
        Returns:
        a collection of completed StepExecution instances
        Throws:
        java.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.
      • createTask

        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.
        Parameters:
        step - the step to execute
        stepExecution - the given execution
        Returns:
        the task executing the given step
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        java.lang.Exception