Class ClusterAwareAggregator

java.lang.Object
org.springframework.batch.core.partition.support.RemoteStepExecutionAggregator
io.github.jchejarla.springbatch.clustering.api.ClusterAwareAggregator
All Implemented Interfaces:
org.springframework.batch.core.partition.StepExecutionAggregator

public class ClusterAwareAggregator extends org.springframework.batch.core.partition.support.RemoteStepExecutionAggregator
An extension of Spring Batch's RemoteStepExecutionAggregator that provides custom callbacks for handling the success or failure of partitioned step executions in a clustered environment.

This aggregator delegates the core aggregation logic to an internal DefaultStepExecutionAggregator but intercepts the final status to invoke specific success or failure callbacks defined by the ClusterAwareAggregatorCallback interface.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ClusterAwareAggregator(ClusterAwareAggregatorCallback clusterAwareAggregatorCallback, org.springframework.batch.core.repository.JobRepository jobRepository)
    Constructs a new ClusterAwareAggregator with the specified callback.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    doHandleFailed(Collection<org.springframework.batch.core.step.StepExecution> executions)
    Handles the failed case for a collection of step executions.
    void
    doHandleSuccess(Collection<org.springframework.batch.core.step.StepExecution> executions)
    Handles the success case for a collection of step executions.

    Methods inherited from class org.springframework.batch.core.partition.support.RemoteStepExecutionAggregator

    aggregate, setDelegate, setJobRepository

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ClusterAwareAggregator

      public ClusterAwareAggregator(ClusterAwareAggregatorCallback clusterAwareAggregatorCallback, org.springframework.batch.core.repository.JobRepository jobRepository)
      Constructs a new ClusterAwareAggregator with the specified callback.
      Parameters:
      clusterAwareAggregatorCallback - The callback to be invoked on success or failure.
      jobRepository - The Spring Batch job repository used to reload persisted partition step executions before aggregation. Required as of Spring Batch 6, which removed the no-argument RemoteStepExecutionAggregator constructor.
  • Method Details

    • doHandleSuccess

      public void doHandleSuccess(Collection<org.springframework.batch.core.step.StepExecution> executions)
      Handles the success case for a collection of step executions. This method simply delegates the call to the configured ClusterAwareAggregatorCallback.onSuccess(Collection).
      Parameters:
      executions - A collection of StepExecution instances that have completed successfully.
    • doHandleFailed

      public void doHandleFailed(Collection<org.springframework.batch.core.step.StepExecution> executions)
      Handles the failed case for a collection of step executions. This method simply delegates the call to the configured ClusterAwareAggregatorCallback.onFailure(Collection).
      Parameters:
      executions - A collection of StepExecution instances where at least one has failed.