Class SmoothRateLimiter.SmoothBursty
- java.lang.Object
-
- com.google.common.util.concurrent.RateLimiter
-
- com.google.common.util.concurrent.SmoothRateLimiter
-
- com.google.common.util.concurrent.SmoothRateLimiter.SmoothBursty
-
- Enclosing class:
- SmoothRateLimiter
static final class SmoothRateLimiter.SmoothBursty extends SmoothRateLimiter
This implements a "bursty" RateLimiter, where storedPermits are translated to zero throttling. The maximum number of permits that can be saved (when the RateLimiter is unused) is defined in terms of time, in this sense: if a RateLimiter is 2qps, and this time is specified as 10 seconds, we can save up to 2 * 10 = 20 permits.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.util.concurrent.SmoothRateLimiter
SmoothRateLimiter.SmoothBursty, SmoothRateLimiter.SmoothWarmingUp
-
Nested classes/interfaces inherited from class com.google.common.util.concurrent.RateLimiter
RateLimiter.SleepingStopwatch
-
-
Field Summary
Fields Modifier and Type Field Description (package private) doublemaxBurstSecondsThe work (permits) of how many seconds can be saved up if this RateLimiter is unused?-
Fields inherited from class com.google.common.util.concurrent.SmoothRateLimiter
maxPermits, stableIntervalMicros, storedPermits
-
-
Constructor Summary
Constructors Constructor Description SmoothBursty(RateLimiter.SleepingStopwatch stopwatch, double maxBurstSeconds)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) doublecoolDownIntervalMicros()Returns the number of microseconds during cool down that we have to wait to get a new permit.(package private) voiddoSetRate(double permitsPerSecond, double stableIntervalMicros)(package private) longstoredPermitsToWaitTime(double storedPermits, double permitsToTake)Translates a specified portion of our currently stored permits which we want to spend/acquire, into a throttling time.-
Methods inherited from class com.google.common.util.concurrent.SmoothRateLimiter
doGetRate, doSetRate, queryEarliestAvailable, reserveEarliestAvailable, resync
-
Methods inherited from class com.google.common.util.concurrent.RateLimiter
acquire, acquire, create, create, create, create, create, getRate, reserve, reserveAndGetWaitLength, setRate, toString, tryAcquire, tryAcquire, tryAcquire, tryAcquire, tryAcquire, tryAcquire
-
-
-
-
Constructor Detail
-
SmoothBursty
SmoothBursty(RateLimiter.SleepingStopwatch stopwatch, double maxBurstSeconds)
-
-
Method Detail
-
doSetRate
void doSetRate(double permitsPerSecond, double stableIntervalMicros)- Specified by:
doSetRatein classSmoothRateLimiter
-
storedPermitsToWaitTime
long storedPermitsToWaitTime(double storedPermits, double permitsToTake)Description copied from class:SmoothRateLimiterTranslates a specified portion of our currently stored permits which we want to spend/acquire, into a throttling time. Conceptually, this evaluates the integral of the underlying function we use, for the range of [(storedPermits - permitsToTake), storedPermits].This always holds:
0 <= permitsToTake <= storedPermits- Specified by:
storedPermitsToWaitTimein classSmoothRateLimiter
-
coolDownIntervalMicros
double coolDownIntervalMicros()
Description copied from class:SmoothRateLimiterReturns the number of microseconds during cool down that we have to wait to get a new permit.- Specified by:
coolDownIntervalMicrosin classSmoothRateLimiter
-
-