Class DispatchRateLimiter

java.lang.Object
org.apache.pulsar.broker.service.persistent.DispatchRateLimiter

public class DispatchRateLimiter extends Object
  • Constructor Details

  • Method Details

    • getAvailableDispatchRateLimitOnMsg

      public long getAvailableDispatchRateLimitOnMsg()
      returns available msg-permit if msg-dispatch-throttling is enabled else it returns -1.
      Returns:
    • getAvailableDispatchRateLimitOnByte

      public long getAvailableDispatchRateLimitOnByte()
      returns available byte-permit if msg-dispatch-throttling is enabled else it returns -1.
      Returns:
    • consumeDispatchQuota

      public void consumeDispatchQuota(long numberOfMessages, long byteSize)
      It acquires msg and bytes permits from rate-limiter and returns if acquired permits succeed.
      Parameters:
      numberOfMessages -
      byteSize -
    • isDispatchRateLimitingEnabled

      public boolean isDispatchRateLimitingEnabled()
      Checks if dispatch-rate limiting is enabled.
      Returns:
    • updateDispatchRate

      public void updateDispatchRate()
      Update dispatch-throttling-rate. Topic-level has the highest priority, then namespace-level, and finally use dispatch-throttling-rate in broker-level
    • getPoliciesAsync

      public static CompletableFuture<Optional<org.apache.pulsar.common.policies.data.Policies>> getPoliciesAsync(BrokerService brokerService, String topicName)
    • getPolicies

      @Deprecated public static Optional<org.apache.pulsar.common.policies.data.Policies> getPolicies(BrokerService brokerService, String topicName)
      Deprecated.
      Avoid using the deprecated method #NamespaceResources.getPoliciesIfCached(NamespaceName) and blocking call. we can use #getPoliciesAsync(BrokerService, String) to instead of it.
    • updateDispatchRate

      public void updateDispatchRate(org.apache.pulsar.common.policies.data.DispatchRate dispatchRate)
      Update dispatch rate by updating msg and byte rate-limiter. If dispatch-rate is configured < 0 then it closes the rate-limiter and disables appropriate rate-limiter.
      Parameters:
      dispatchRate -
    • getDispatchRateOnMsg

      public long getDispatchRateOnMsg()
      Get configured msg dispatch-throttling rate. Returns -1 if not configured
      Returns:
    • getDispatchRateOnByte

      public long getDispatchRateOnByte()
      Get configured byte dispatch-throttling rate. Returns -1 if not configured
      Returns:
    • isDispatchRateEnabled

      public static boolean isDispatchRateEnabled(org.apache.pulsar.common.policies.data.DispatchRate dispatchRate)
    • close

      public void close()