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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassignPartitions(List<org.springframework.batch.infrastructure.item.ExecutionContext> executionContexts, List<ClusterNode> availableNodes) Assigns partitions to a fixed number of nodes using a round-robin approach.
-
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:
assignPartitionsin interfacePartitionAssignmentStrategy- Parameters:
executionContexts- The list ofExecutionContextinstances representing the partitions.availableNodes- The list of available node IDs in the cluster.- Returns:
- A list of
PartitionAssignmentobjects representing the assignment of partitions to nodes.
-