org.springframework.batch.core.partition.support

## Class SimpleStepExecutionSplitter

- java.lang.Object
- - org.springframework.batch.core.partition.support.SimpleStepExecutionSplitter

- All Implemented Interfaces:
    StepExecutionSplitter, org.springframework.beans.factory.InitializingBean
  Direct Known Subclasses:
    JsrStepExecutionSplitter

      public class SimpleStepExecutionSplitter
      extends java.lang.Object
      implements StepExecutionSplitter, org.springframework.beans.factory.InitializingBean

  Generic implementation of `StepExecutionSplitter` that delegates to a `Partitioner` to generate `ExecutionContext` instances. Takes care of restartability and identifying the step executions from previous runs of the same job. The generated `StepExecution` instances have names that identify them uniquely in the partition. The name is constructed from a base (name of the target step) plus a suffix taken from the `Partitioner` identifiers, separated by a colon, e.g. `{step1:partition0, step1:partition1, ...}`.
  Since:
    2.0
  Author:
    Dave Syer

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleStepExecutionSplitter()` Default constructor for convenience in configuration.
    `SimpleStepExecutionSplitter(JobRepository jobRepository, boolean allowStartIfComplete, java.lang.String stepName, Partitioner partitioner)` Construct a `SimpleStepExecutionSplitter` from its mandatory properties.
    `SimpleStepExecutionSplitter(JobRepository jobRepository, Step step, Partitioner partitioner)` Deprecated. use `SimpleStepExecutionSplitter(JobRepository, boolean, String, Partitioner)` instead

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()` Check mandatory properties (step name, job repository and partitioner).
    `protected boolean` | `getStartable(StepExecution stepExecution, ExecutionContext context)`
    `java.lang.String` | `getStepName()` The name of the step configuration that will be executed remotely.
    `void` | `setAllowStartIfComplete(boolean allowStartIfComplete)` Flag to indicate that the partition target step is allowed to start if an execution is complete.
    `void` | `setJobRepository(JobRepository jobRepository)` The job repository that will be used to manage the persistence of the delegate step executions.
    `void` | `setPartitioner(Partitioner partitioner)` The `Partitioner` that will be used to generate step execution meta data for the target step.
    `void` | `setStepName(java.lang.String stepName)` The name of the target step that will be executed across the partitions.
    `java.util.Set<StepExecution>` | `split(StepExecution stepExecution, int gridSize)` Partition the provided `StepExecution` into a set of parallel executable instances with the same parent `JobExecution`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SimpleStepExecutionSplitter

          public SimpleStepExecutionSplitter()

      Default constructor for convenience in configuration.

    - #### SimpleStepExecutionSplitter

          public SimpleStepExecutionSplitter(JobRepository jobRepository,
                                             boolean allowStartIfComplete,
                                             java.lang.String stepName,
                                             Partitioner partitioner)

      Construct a `SimpleStepExecutionSplitter` from its mandatory properties.
      Parameters:
        `jobRepository` - the `JobRepository`
        `allowStartIfComplete` - flag specifying preferences on restart
        `stepName` - the target step name
        `partitioner` - a `Partitioner` to use for generating input parameters

    - #### SimpleStepExecutionSplitter

          @Deprecated
          public SimpleStepExecutionSplitter(JobRepository jobRepository,
                                                         Step step,
                                                         Partitioner partitioner)

      Deprecated. use `SimpleStepExecutionSplitter(JobRepository, boolean, String, Partitioner)` instead
      Construct a `SimpleStepExecutionSplitter` from its mandatory properties.
      Parameters:
        `jobRepository` - the `JobRepository`
        `step` - the target step (a local version of it), used to extract the name and allowStartIfComplete flags
        `partitioner` - a `Partitioner` to use for generating input parameters

  - ### Method Detail

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws java.lang.Exception

      Check mandatory properties (step name, job repository and partitioner).
      Specified by:
        `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
      Throws:
        `java.lang.Exception`
      See Also:
        `InitializingBean.afterPropertiesSet()`

    - #### setAllowStartIfComplete

          public void setAllowStartIfComplete(boolean allowStartIfComplete)

      Flag to indicate that the partition target step is allowed to start if an execution is complete. Defaults to the same value as the underlying step. Set this manually to override the underlying step properties.
      Parameters:
        `allowStartIfComplete` - the value to set
      See Also:
        `Step.isAllowStartIfComplete()`

    - #### setJobRepository

          public void setJobRepository(JobRepository jobRepository)

      The job repository that will be used to manage the persistence of the delegate step executions.
      Parameters:
        `jobRepository` - the JobRepository to set

    - #### setPartitioner

          public void setPartitioner(Partitioner partitioner)

      The `Partitioner` that will be used to generate step execution meta data for the target step.
      Parameters:
        `partitioner` - the partitioner to set

    - #### setStepName

          public void setStepName(java.lang.String stepName)

      The name of the target step that will be executed across the partitions. Mandatory with no default.
      Parameters:
        `stepName` - the step name to set

    - #### getStepName

          public java.lang.String getStepName()

      Description copied from interface: `StepExecutionSplitter`
      The name of the step configuration that will be executed remotely. Remote workers are going to execute a the same step for each execution context in the partition.
      Specified by:
        `getStepName` in interface `StepExecutionSplitter`
      Returns:
        the name of the step that will execute the business logic
      See Also:
        `StepExecutionSplitter.getStepName()`

    - #### split

          public java.util.Set<StepExecution> split(StepExecution stepExecution,
                                                    int gridSize)
                                             throws JobExecutionException

      Description copied from interface: `StepExecutionSplitter`
      Partition the provided `StepExecution` into a set of parallel executable instances with the same parent `JobExecution`. The grid size will be treated as a hint for the size of the collection to be returned. It may or may not correspond to the physical size of an execution grid.
      On a restart clients of the `StepExecutionSplitter` should expect it to reconstitute the state of the last failed execution and only return those executions that need to be restarted. Thus the grid size hint will be ignored on a restart.
      Specified by:
        `split` in interface `StepExecutionSplitter`
      Parameters:
        `stepExecution` - the `StepExecution` to be partitioned.
        `gridSize` - a hint for the splitter if the size of the grid is known
      Returns:
        a set of `StepExecution` instances for remote processing
      Throws:
        `JobExecutionException` - if the split cannot be made
      See Also:
        `StepExecutionSplitter.split(StepExecution, int)`

    - #### getStartable

          protected boolean getStartable(StepExecution stepExecution,
                                         ExecutionContext context)
                                  throws JobExecutionException

      Throws:
        `JobExecutionException`