Package org.apache.pulsar.broker.service
Class DrainingHashesTracker
java.lang.Object
org.apache.pulsar.broker.service.DrainingHashesTracker
A thread-safe map to store draining hashes in the consumer.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents an entry in the draining hashes tracker.static interfaceInterface for handling the unblocking of sticky key hashes. -
Constructor Summary
ConstructorsConstructorDescriptionDrainingHashesTracker(String dispatcherName, DrainingHashesTracker.UnblockingHandler unblockingHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an entry to the draining hashes tracker.voidclear()Clear all entries in the draining hashes tracker.voidconsumerRemoved(Consumer consumer) Remove the consumer specific stats from the draining hashes tracker.voidendBatch()End a batch operation.getEntry(int stickyKeyHash) Get the entry for a given sticky key hash.voidreduceRefCount(Consumer consumer, int stickyHash, boolean closing) Reduce the reference count for a given sticky hash.booleanshouldBlockStickyKeyHash(Consumer consumer, int stickyKeyHash) Check if a sticky key hash should be blocked.voidStart a batch operation.voidupdateConsumerStats(Consumer consumer, org.apache.pulsar.common.policies.data.stats.ConsumerStatsImpl consumerStats) Update the consumer specific stats to the targetConsumerStatsImpl.
-
Constructor Details
-
DrainingHashesTracker
public DrainingHashesTracker(String dispatcherName, DrainingHashesTracker.UnblockingHandler unblockingHandler)
-
-
Method Details
-
addEntry
Add an entry to the draining hashes tracker.- Parameters:
consumer- the consumerstickyHash- the sticky hash
-
startBatch
public void startBatch()Start a batch operation. There could be multiple nested batch operations. The unblocking of sticky key hashes will be done only when the last batch operation ends. -
endBatch
public void endBatch()End a batch operation. -
reduceRefCount
Reduce the reference count for a given sticky hash.- Parameters:
consumer- the consumerstickyHash- the sticky hashclosing-
-
shouldBlockStickyKeyHash
Check if a sticky key hash should be blocked.- Parameters:
consumer- the consumerstickyKeyHash- the sticky key hash- Returns:
- true if the sticky key hash should be blocked, false otherwise
-
getEntry
Get the entry for a given sticky key hash.- Parameters:
stickyKeyHash- the sticky key hash- Returns:
- the draining hash entry, or null if not found
-
clear
public void clear()Clear all entries in the draining hashes tracker. -
updateConsumerStats
public void updateConsumerStats(Consumer consumer, org.apache.pulsar.common.policies.data.stats.ConsumerStatsImpl consumerStats) Update the consumer specific stats to the targetConsumerStatsImpl.- Parameters:
consumer- the consumerconsumerStats- the consumer stats to update the values to
-
consumerRemoved
Remove the consumer specific stats from the draining hashes tracker.- Parameters:
consumer- the consumer
-