Class RateLimiter


  • public class RateLimiter
    extends java.lang.Object
    Rate limiter implementation is based on token bucket algorithm. There are two parameters:
    • burst size - maximum number of requests allowed into the system as a burst
    • average rate - expected number of requests per second (RateLimiters using MINUTES is also supported)
    • Constructor Summary

      Constructors 
      Constructor Description
      RateLimiter()
      Deprecated.
      RateLimiter​(java.util.concurrent.TimeUnit averageRateUnit)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean acquire​(int burstSize, long averageRate)  
      boolean acquire​(int burstSize, long averageRate, long currentTimeMillis)  
      void reset()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RateLimiter

        @Deprecated
        public RateLimiter()
        Deprecated.
      • RateLimiter

        public RateLimiter​(java.util.concurrent.TimeUnit averageRateUnit)
    • Method Detail

      • acquire

        public boolean acquire​(int burstSize,
                               long averageRate)
      • acquire

        public boolean acquire​(int burstSize,
                               long averageRate,
                               long currentTimeMillis)
      • reset

        public void reset()