Class CooperativeStickyAssignor
java.lang.Object
org.apache.kafka.clients.consumer.internals.AbstractPartitionAssignor
org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor
org.apache.kafka.clients.consumer.CooperativeStickyAssignor
- All Implemented Interfaces:
- ConsumerPartitionAssignor
public class CooperativeStickyAssignor
extends org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor
A cooperative version of the 
AbstractStickyAssignor. This follows the same (sticky)
 assignment logic as StickyAssignor but allows for cooperative rebalancing while the
 StickyAssignor follows the eager rebalancing protocol. See
 ConsumerPartitionAssignor.RebalanceProtocol for an explanation of the rebalancing protocols.
 Users should prefer this assignor for newer clusters.
 To turn on cooperative rebalancing you must set all your consumers to use this PartitionAssignor,
 or implement a custom one that returns RebalanceProtocol.COOPERATIVE in
 supportedProtocols().
 
IMPORTANT: if upgrading from 2.3 or earlier, you must follow a specific upgrade path in order to safely turn on cooperative rebalancing. See the upgrade guide for details.
- 
Nested Class SummaryNested classes/interfaces inherited from class org.apache.kafka.clients.consumer.internals.AbstractStickyAssignororg.apache.kafka.clients.consumer.internals.AbstractStickyAssignor.MemberDataNested classes/interfaces inherited from class org.apache.kafka.clients.consumer.internals.AbstractPartitionAssignororg.apache.kafka.clients.consumer.internals.AbstractPartitionAssignor.MemberInfoNested classes/interfaces inherited from interface org.apache.kafka.clients.consumer.ConsumerPartitionAssignorConsumerPartitionAssignor.Assignment, ConsumerPartitionAssignor.GroupAssignment, ConsumerPartitionAssignor.GroupSubscription, ConsumerPartitionAssignor.RebalanceProtocol, ConsumerPartitionAssignor.Subscription
- 
Field SummaryFieldsFields inherited from class org.apache.kafka.clients.consumer.internals.AbstractStickyAssignorDEFAULT_GENERATION, maxGeneration, partitionsTransferringOwnership
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionassign(Map<String, Integer> partitionsPerTopic, Map<String, ConsumerPartitionAssignor.Subscription> subscriptions) protected org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor.MemberDatamemberData(ConsumerPartitionAssignor.Subscription subscription) name()Unique name for this assignor (e.g.voidonAssignment(ConsumerPartitionAssignor.Assignment assignment, ConsumerGroupMetadata metadata) Callback which is invoked when a group member receives its assignment from the leader.subscriptionUserData(Set<String> topics) Return serialized data that will be included in theConsumerPartitionAssignor.Subscriptionsent to the leader and can be leveraged inConsumerPartitionAssignor.assign(Cluster, GroupSubscription)((e.g. local host/rack information)Indicate which rebalance protocol this assignor works with; By default it should always work withConsumerPartitionAssignor.RebalanceProtocol.EAGER.Methods inherited from class org.apache.kafka.clients.consumer.internals.AbstractStickyAssignorisStickyMethods inherited from class org.apache.kafka.clients.consumer.internals.AbstractPartitionAssignorassign, partitions, putMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.kafka.clients.consumer.ConsumerPartitionAssignorversion
- 
Field Details- 
COOPERATIVE_STICKY_ASSIGNOR_NAME- See Also:
 
 
- 
- 
Constructor Details- 
CooperativeStickyAssignorpublic CooperativeStickyAssignor()
 
- 
- 
Method Details- 
nameDescription copied from interface:ConsumerPartitionAssignorUnique name for this assignor (e.g. "range" or "roundrobin" or "sticky"). Note, this is not required to be the same as the class name specified inConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG- Returns:
- non-null unique name
 
- 
supportedProtocolsDescription copied from interface:ConsumerPartitionAssignorIndicate which rebalance protocol this assignor works with; By default it should always work withConsumerPartitionAssignor.RebalanceProtocol.EAGER.
- 
onAssignmentpublic void onAssignment(ConsumerPartitionAssignor.Assignment assignment, ConsumerGroupMetadata metadata) Description copied from interface:ConsumerPartitionAssignorCallback which is invoked when a group member receives its assignment from the leader.- Parameters:
- assignment- The local member's assignment as provided by the leader in- ConsumerPartitionAssignor.assign(Cluster, GroupSubscription)
- metadata- Additional metadata on the consumer (optional)
 
- 
subscriptionUserDataDescription copied from interface:ConsumerPartitionAssignorReturn serialized data that will be included in theConsumerPartitionAssignor.Subscriptionsent to the leader and can be leveraged inConsumerPartitionAssignor.assign(Cluster, GroupSubscription)((e.g. local host/rack information)- Parameters:
- topics- Topics subscribed to through- KafkaConsumer.subscribe(java.util.Collection)and variants
- Returns:
- nullable subscription user data
 
- 
memberDataprotected org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor.MemberData memberData(ConsumerPartitionAssignor.Subscription subscription) - Specified by:
- memberDatain class- org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor
 
- 
assignpublic Map<String,List<TopicPartition>> assign(Map<String, Integer> partitionsPerTopic, Map<String, ConsumerPartitionAssignor.Subscription> subscriptions) - Overrides:
- assignin class- org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor
 
 
-