Package io.atomix.raft.partition
Class RoundRobinPartitionDistributor
java.lang.Object
io.atomix.raft.partition.RoundRobinPartitionDistributor
- All Implemented Interfaces:
PartitionDistributor
This implementation of
PartitionDistributor distributes the partitions in a round robin
fashion over the set of members in the cluster.
Example distribution with 4 members, 5 partitions, and a replication factor of 3
+------------------+----+----+----+---+ | Partition \ Node | 0 | 1 | 2 | 3 | +------------------+----+----+----+---+ | 1 | 3 | 2 | 1 | | | 2 | | 3 | 2 | 1 | | 3 | 1 | | 3 | 2 | | 4 | 2 | 1 | | 3 | | 5 | 3 | 1 | 2 | | +------------------+----+----+----+---+
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondistributePartitions(Set<MemberId> clusterMembers, List<PartitionId> sortedPartitionIds, int replicationFactor) Provides the partition distribution based on the given list of partition IDs, cluster members, and the replication factor.
-
Constructor Details
-
RoundRobinPartitionDistributor
public RoundRobinPartitionDistributor()
-
-
Method Details
-
distributePartitions
public Set<PartitionMetadata> distributePartitions(Set<MemberId> clusterMembers, List<PartitionId> sortedPartitionIds, int replicationFactor) Description copied from interface:PartitionDistributorProvides the partition distribution based on the given list of partition IDs, cluster members, and the replication factor. The set of partitions returned is guaranteed to be correctly replicated.- Specified by:
distributePartitionsin interfacePartitionDistributor- Parameters:
clusterMembers- the set of members that can own partitionssortedPartitionIds- a sorted list of partition IDsreplicationFactor- the replication factor for each partition- Returns:
- a set of distributed partitions, each specifying which members they belong to
-