Package org.apache.pulsar.broker.service
Class HashRangeExclusiveStickyKeyConsumerSelector
java.lang.Object
org.apache.pulsar.broker.service.HashRangeExclusiveStickyKeyConsumerSelector
- All Implemented Interfaces:
StickyKeyConsumerSelector
public class HashRangeExclusiveStickyKeyConsumerSelector
extends Object
implements StickyKeyConsumerSelector
This is a sticky-key consumer selector based user provided range.
User is responsible for making sure provided range for all consumers cover the rangeSize
else there'll be chance that a key fall in a `whole` that not handled by any consumer.
-
Field Summary
Fields inherited from interface org.apache.pulsar.broker.service.StickyKeyConsumerSelector
DEFAULT_RANGE_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConsumer(Consumer consumer) Add a new consumer.Get key hash ranges handled by each consumer.voidremoveConsumer(Consumer consumer) Remove the consumer.select(int hash) Select a consumer by hash.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pulsar.broker.service.StickyKeyConsumerSelector
select
-
Constructor Details
-
HashRangeExclusiveStickyKeyConsumerSelector
public HashRangeExclusiveStickyKeyConsumerSelector() -
HashRangeExclusiveStickyKeyConsumerSelector
public HashRangeExclusiveStickyKeyConsumerSelector(int rangeSize)
-
-
Method Details
-
addConsumer
Description copied from interface:StickyKeyConsumerSelectorAdd a new consumer.- Specified by:
addConsumerin interfaceStickyKeyConsumerSelector- Parameters:
consumer- new consumer- Throws:
BrokerServiceException.ConsumerAssignException
-
removeConsumer
Description copied from interface:StickyKeyConsumerSelectorRemove the consumer.- Specified by:
removeConsumerin interfaceStickyKeyConsumerSelector- Parameters:
consumer- consumer to be removed
-
getConsumerKeyHashRanges
Description copied from interface:StickyKeyConsumerSelectorGet key hash ranges handled by each consumer.- Specified by:
getConsumerKeyHashRangesin interfaceStickyKeyConsumerSelector- Returns:
- A map where key is a consumer name and value is list of hash range it receiving message for.
-
select
Description copied from interface:StickyKeyConsumerSelectorSelect a consumer by hash.- Specified by:
selectin interfaceStickyKeyConsumerSelector- Parameters:
hash- hash corresponding to sticky key- Returns:
- consumer
-