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
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.SmoothWarmingUpNested classes/interfaces inherited from class com.google.common.util.concurrent.RateLimiter
RateLimiter.SleepingStopwatch -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final doubleThe 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
ConstructorsConstructorDescriptionSmoothBursty(RateLimiter.SleepingStopwatch stopwatch, double maxBurstSeconds) -
Method Summary
Modifier and TypeMethodDescription(package private) doubleReturns 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, resyncMethods 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
-
Field Details
-
maxBurstSeconds
final double maxBurstSecondsThe work (permits) of how many seconds can be saved up if this RateLimiter is unused?
-
-
Constructor Details
-
SmoothBursty
SmoothBursty(RateLimiter.SleepingStopwatch stopwatch, double maxBurstSeconds)
-
-
Method Details
-
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
-