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:
    • tryDispatchPermit

      public boolean tryDispatchPermit(long msgPermits, long bytePermits)
      It acquires msg and bytes permits from rate-limiter and returns if acquired permits succeed.
      Parameters:
      msgPermits -
      bytePermits -
      Returns:
    • hasMessageDispatchPermit

      public boolean hasMessageDispatchPermit()
      checks if dispatch-rate limit is configured and if it's configured then check if permits are available or not.
      Returns:
    • 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

      public static Optional<org.apache.pulsar.common.policies.data.Policies> getPolicies(BrokerService brokerService, String topicName)
    • 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()