Package com.linkedin.venice.throttle
Class GuavaRateLimiter
java.lang.Object
com.linkedin.venice.throttle.GuavaRateLimiter
- All Implemented Interfaces:
VeniceRateLimiter
A wrapper around Guava's RateLimiter to provide a common interface for rate limiting.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.linkedin.venice.throttle.VeniceRateLimiter
VeniceRateLimiter.RateLimiterType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidacquirePermit(int units) Acquire a permit, blocking until one is available.longgetQuota()voidsetQuota(long quota) The following methods are used only when checking if the new quota requests are different from the existing quota.toString()booleantryAcquirePermit(int units) Try to acquire permit for the given rcu.
-
Constructor Details
-
GuavaRateLimiter
public GuavaRateLimiter(long permitsPerSecond)
-
-
Method Details
-
tryAcquirePermit
public boolean tryAcquirePermit(int units) Description copied from interface:VeniceRateLimiterTry to acquire permit for the given rcu. Will not block if permit is not available.- Specified by:
tryAcquirePermitin interfaceVeniceRateLimiter- Parameters:
units- Number of units to acquire.- Returns:
- true if permit is acquired, false otherwise.
-
acquirePermit
public void acquirePermit(int units) Description copied from interface:VeniceRateLimiterAcquire a permit, blocking until one is available. Default implementation pollsVeniceRateLimiter.tryAcquirePermit(int)with a 10ms sleep. Implementations with native blocking (e.g. Guava RateLimiter) should override for precision.- Specified by:
acquirePermitin interfaceVeniceRateLimiter
-
setQuota
public void setQuota(long quota) Description copied from interface:VeniceRateLimiterThe following methods are used only when checking if the new quota requests are different from the existing quota.- Specified by:
setQuotain interfaceVeniceRateLimiter
-
getQuota
public long getQuota()- Specified by:
getQuotain interfaceVeniceRateLimiter
-
toString
-