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.SmoothWarmingUp
Nested classes/interfaces inherited from class com.google.common.util.concurrent.RateLimiter
RateLimiter.SleepingStopwatch
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final double
The 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) double
Returns the number of microseconds during cool down that we have to wait to get a new permit.(package private) void
doSetRate
(double permitsPerSecond, double stableIntervalMicros) (package private) long
storedPermitsToWaitTime
(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
-
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:
doSetRate
in classSmoothRateLimiter
-
storedPermitsToWaitTime
long storedPermitsToWaitTime(double storedPermits, double permitsToTake) Description copied from class:SmoothRateLimiter
Translates 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:
storedPermitsToWaitTime
in classSmoothRateLimiter
-
coolDownIntervalMicros
double coolDownIntervalMicros()Description copied from class:SmoothRateLimiter
Returns the number of microseconds during cool down that we have to wait to get a new permit.- Specified by:
coolDownIntervalMicros
in classSmoothRateLimiter
-