Class FixedNodeCountPartitionAssignmentStrategy

java.lang.Object
io.github.jchejarla.springbatch.clustering.partition.impl.FixedNodeCountPartitionAssignmentStrategy
All Implemented Interfaces:
PartitionAssignmentStrategy

public class FixedNodeCountPartitionAssignmentStrategy extends Object implements PartitionAssignmentStrategy
A partition strategy that assigns partitions to a fixed number of nodes.

This strategy selects a specified number of nodes and distributes partitions among them using a round-robin approach. If the number of available nodes is less than the fixed node count, it uses all available nodes.

Author:
Janardhan Chejarla
  • Constructor Details

    • FixedNodeCountPartitionAssignmentStrategy

      public FixedNodeCountPartitionAssignmentStrategy()
  • Method Details

    • assignPartitions

      public List<PartitionAssignment> assignPartitions(List<org.springframework.batch.infrastructure.item.ExecutionContext> executionContexts, List<ClusterNode> availableNodes)
      Assigns partitions to a fixed number of nodes using a round-robin approach.
      Specified by:
      assignPartitions in interface PartitionAssignmentStrategy
      Parameters:
      executionContexts - The list of ExecutionContext instances representing the partitions.
      availableNodes - The list of available node IDs in the cluster.
      Returns:
      A list of PartitionAssignment objects representing the assignment of partitions to nodes.