Class AbstractPartitionAssignor
java.lang.Object
org.apache.kafka.clients.consumer.internals.AbstractPartitionAssignor
- All Implemented Interfaces:
ConsumerPartitionAssignor
- Direct Known Subclasses:
AbstractStickyAssignor,RangeAssignor,RoundRobinAssignor
Abstract assignor implementation which does some common grunt work (in particular collecting
partition counts which are always needed in assignors).
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.kafka.clients.consumer.ConsumerPartitionAssignor
ConsumerPartitionAssignor.Assignment, ConsumerPartitionAssignor.GroupAssignment, ConsumerPartitionAssignor.GroupSubscription, ConsumerPartitionAssignor.RebalanceProtocol, ConsumerPartitionAssignor.Subscription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassign(Map<String, Integer> partitionsPerTopic, Map<String, ConsumerPartitionAssignor.Subscription> subscriptions) Perform the group assignment given the partition counts and member subscriptionsassign(org.apache.kafka.common.Cluster metadata, ConsumerPartitionAssignor.GroupSubscription groupSubscription) Perform the group assignment given the member subscriptions and current cluster metadata.assignPartitions(Map<String, List<org.apache.kafka.common.PartitionInfo>> partitionsPerTopic, Map<String, ConsumerPartitionAssignor.Subscription> subscriptions) Default implementation of assignPartitions() that does not include racks.partitionInfosWithoutRacks(Map<String, Integer> partitionsPerTopic) protected static List<org.apache.kafka.common.TopicPartition> partitions(String topic, int numPartitions) protected static <K,V> void protected booleanuseRackAwareAssignment(Set<String> consumerRacks, Set<String> partitionRacks, Map<org.apache.kafka.common.TopicPartition, Set<String>> racksPerPartition) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.kafka.clients.consumer.ConsumerPartitionAssignor
name, onAssignment, subscriptionUserData, supportedProtocols, version
-
Constructor Details
-
AbstractPartitionAssignor
public AbstractPartitionAssignor()
-
-
Method Details
-
assign
public abstract Map<String,List<org.apache.kafka.common.TopicPartition>> assign(Map<String, Integer> partitionsPerTopic, Map<String, ConsumerPartitionAssignor.Subscription> subscriptions) Perform the group assignment given the partition counts and member subscriptions- Parameters:
partitionsPerTopic- The number of partitions for each subscribed topic. Topics not in metadata will be excluded from this map.subscriptions- Map from the member id to their respective topic subscription- Returns:
- Map from each member to the list of partitions assigned to them.
-
assignPartitions
public Map<String,List<org.apache.kafka.common.TopicPartition>> assignPartitions(Map<String, List<org.apache.kafka.common.PartitionInfo>> partitionsPerTopic, Map<String, ConsumerPartitionAssignor.Subscription> subscriptions) Default implementation of assignPartitions() that does not include racks. This is only included to avoid breaking any custom implementation that extends AbstractPartitionAssignor. Note that this class is internal, but to be safe, we are maintaining compatibility. -
assign
public ConsumerPartitionAssignor.GroupAssignment assign(org.apache.kafka.common.Cluster metadata, ConsumerPartitionAssignor.GroupSubscription groupSubscription) Description copied from interface:ConsumerPartitionAssignorPerform the group assignment given the member subscriptions and current cluster metadata.- Specified by:
assignin interfaceConsumerPartitionAssignor- Parameters:
metadata- Current topic/broker metadata known by consumergroupSubscription- Subscriptions from all members including metadata provided throughConsumerPartitionAssignor.subscriptionUserData(Set)- Returns:
- A map from the members to their respective assignments. This should have one entry for each member in the input subscription map.
-
put
-
partitions
-
partitionInfosWithoutRacks
-
useRackAwareAssignment
-