public class CooperativeStickyAssignor
extends org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor
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.
org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor.MemberData
org.apache.kafka.clients.consumer.internals.AbstractPartitionAssignor.MemberInfo
ConsumerPartitionAssignor.Assignment, ConsumerPartitionAssignor.GroupAssignment, ConsumerPartitionAssignor.GroupSubscription, ConsumerPartitionAssignor.RebalanceProtocol, ConsumerPartitionAssignor.Subscription
Constructor and Description |
---|
CooperativeStickyAssignor() |
Modifier and Type | Method and Description |
---|---|
Map<String,List<TopicPartition>> |
assign(Map<String,Integer> partitionsPerTopic,
Map<String,ConsumerPartitionAssignor.Subscription> subscriptions) |
protected org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor.MemberData |
memberData(ConsumerPartitionAssignor.Subscription subscription) |
String |
name()
Unique name for this assignor (e.g.
|
List<ConsumerPartitionAssignor.RebalanceProtocol> |
supportedProtocols()
Indicate which rebalance protocol this assignor works with;
By default it should always work with
ConsumerPartitionAssignor.RebalanceProtocol.EAGER . |
isSticky
assign, partitions, put
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onAssignment, subscriptionUserData, version
public String name()
ConsumerPartitionAssignor
ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG
public List<ConsumerPartitionAssignor.RebalanceProtocol> supportedProtocols()
ConsumerPartitionAssignor
ConsumerPartitionAssignor.RebalanceProtocol.EAGER
.protected org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor.MemberData memberData(ConsumerPartitionAssignor.Subscription subscription)
memberData
in class org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor
public Map<String,List<TopicPartition>> assign(Map<String,Integer> partitionsPerTopic, Map<String,ConsumerPartitionAssignor.Subscription> subscriptions)
assign
in class org.apache.kafka.clients.consumer.internals.AbstractStickyAssignor