Class GuavaRateLimiter

  • All Implemented Interfaces:
    VeniceRateLimiter

    public class GuavaRateLimiter
    extends java.lang.Object
    implements VeniceRateLimiter
    A wrapper around Guava's RateLimiter to provide a common interface for rate limiting.
    • Constructor Summary

      Constructors 
      Constructor Description
      GuavaRateLimiter​(long permitsPerSecond)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getQuota()  
      void setQuota​(long quota)
      The following methods are used only when checking if the new quota requests are different from the existing quota.
      java.lang.String toString()  
      boolean tryAcquirePermit​(int units)
      Try to acquire permit for the given rcu.
      • Methods inherited from class java.lang.Object

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

      • GuavaRateLimiter

        public GuavaRateLimiter​(long permitsPerSecond)
    • Method Detail

      • tryAcquirePermit

        public boolean tryAcquirePermit​(int units)
        Description copied from interface: VeniceRateLimiter
        Try to acquire permit for the given rcu. Will not block if permit is not available.
        Specified by:
        tryAcquirePermit in interface VeniceRateLimiter
        Parameters:
        units - Number of units to acquire.
        Returns:
        true if permit is acquired, false otherwise.
      • setQuota

        public void setQuota​(long quota)
        Description copied from interface: VeniceRateLimiter
        The following methods are used only when checking if the new quota requests are different from the existing quota.
        Specified by:
        setQuota in interface VeniceRateLimiter
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object