@InterfaceAudience.Private @InterfaceStability.Evolving public class FixedIntervalRateLimiter extends RateLimiter
| Modifier and Type | Field and Description |
|---|---|
static String |
RATE_LIMITER_REFILL_INTERVAL_MS
The FixedIntervalRateLimiter can be harsh from a latency/backoff perspective, which makes it
difficult to fully and consistently utilize a quota allowance.
|
DEFAULT_TIME_UNIT, QUOTA_RATE_LIMITER_CONF_KEY| Constructor and Description |
|---|
FixedIntervalRateLimiter() |
FixedIntervalRateLimiter(long refillInterval) |
| Modifier and Type | Method and Description |
|---|---|
long |
getNextRefillTime() |
long |
getWaitInterval(long limit,
long available,
long amount)
Time in milliseconds to wait for before requesting to consume 'amount' resource.
|
long |
refill(long limit)
Refill the available units w.r.t the elapsed time.
|
void |
setNextRefillTime(long nextRefillTime) |
consume, consume, getAvailable, getLimit, getTimeUnitInMillis, getWaitIntervalMs, getWaitIntervalMs, isAvailable, isBypass, set, toString, update, waitInterval, waitIntervalpublic static final String RATE_LIMITER_REFILL_INTERVAL_MS
RATE_LIMITER_REFILL_INTERVAL_MS to a lower value you will encourage the rate limiter
to throw smaller wait intervals for requests which may be fulfilled in timeframes shorter than
the quota's full interval. For example, if you're saturating a 100MB/sec read IO quota with a
ton of tiny gets, then configuring this to a value like 100ms will ensure that your retry
backoffs approach ~100ms, rather than 1sec. Be careful not to configure this too low, or you
may produce a dangerous amount of retry volume.public FixedIntervalRateLimiter()
public FixedIntervalRateLimiter(long refillInterval)
public long refill(long limit)
RateLimiterlimit - Maximum available resource units that can be refilled to.public long getWaitInterval(long limit,
long available,
long amount)
RateLimiterlimit - Maximum available resource units that can be refilled to.available - Currently available resource unitsamount - Resources for which time interval to calculate forpublic void setNextRefillTime(long nextRefillTime)
setNextRefillTime in class RateLimiterpublic long getNextRefillTime()
getNextRefillTime in class RateLimiterCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.