Class PublishRateLimiterImpl

java.lang.Object
org.apache.pulsar.broker.service.PublishRateLimiterImpl
All Implemented Interfaces:
PublishRateLimiter
Direct Known Subclasses:
ResourceGroupPublishLimiter

public class PublishRateLimiterImpl extends Object implements PublishRateLimiter
  • Constructor Details

  • Method Details

    • handlePublishThrottling

      public void handlePublishThrottling(Producer producer, int numOfMessages, long msgSizeInBytes)
      Consumes publishing quota and handles throttling.

      The rate limiter implementation calls Producer.incrementThrottleCount() to indicate that the producer should be throttled. The rate limiter must schedule a call to Producer.decrementThrottleCount() after a throttling period that it calculates.

      Specified by:
      handlePublishThrottling in interface PublishRateLimiter
      numOfMessages - number of messages to publish
      msgSizeInBytes - size of messages in bytes to publish
    • update

      public void update(org.apache.pulsar.common.policies.data.Policies policies, String clusterName)
      Description copied from interface: PublishRateLimiter
      updates rate-limiting threshold based on policies.
      Specified by:
      update in interface PublishRateLimiter
    • update

      public void update(org.apache.pulsar.common.policies.data.PublishRate maxPublishRate)
      Description copied from interface: PublishRateLimiter
      updates rate-limiting threshold based on passed in rate limiter.
      Specified by:
      update in interface PublishRateLimiter
    • updateTokenBuckets

      protected void updateTokenBuckets(long publishThrottlingRateInMsg, long publishThrottlingRateInByte)
    • getTokenBucketOnMessage

      public AsyncTokenBucket getTokenBucketOnMessage()
    • getTokenBucketOnByte

      public AsyncTokenBucket getTokenBucketOnByte()