Class DrainingHashesTracker

java.lang.Object
org.apache.pulsar.broker.service.DrainingHashesTracker

public class DrainingHashesTracker extends Object
A thread-safe map to store draining hashes in the consumer.
  • Constructor Details

  • Method Details

    • addEntry

      public void addEntry(Consumer consumer, int stickyHash)
      Add an entry to the draining hashes tracker.
      Parameters:
      consumer - the consumer
      stickyHash - 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

      public void reduceRefCount(Consumer consumer, int stickyHash, boolean closing)
      Reduce the reference count for a given sticky hash.
      Parameters:
      consumer - the consumer
      stickyHash - the sticky hash
      closing -
    • shouldBlockStickyKeyHash

      public boolean shouldBlockStickyKeyHash(Consumer consumer, int stickyKeyHash)
      Check if a sticky key hash should be blocked.
      Parameters:
      consumer - the consumer
      stickyKeyHash - the sticky key hash
      Returns:
      true if the sticky key hash should be blocked, false otherwise
    • getEntry

      public DrainingHashesTracker.DrainingHashEntry getEntry(int stickyKeyHash)
      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 target ConsumerStatsImpl.
      Parameters:
      consumer - the consumer
      consumerStats - the consumer stats to update the values to
    • consumerRemoved

      public void consumerRemoved(Consumer consumer)
      Remove the consumer specific stats from the draining hashes tracker.
      Parameters:
      consumer - the consumer