@InterfaceAudience.Private @InterfaceStability.Evolving public abstract class RateLimiter extends Object
Modifier and Type | Field and Description |
---|---|
static String |
QUOTA_RATE_LIMITER_CONF_KEY |
Constructor and Description |
---|
RateLimiter() |
Modifier and Type | Method and Description |
---|---|
boolean |
canExecute()
Is there at least one resource available to allow execution?
|
boolean |
canExecute(long amount)
Are there enough available resources to allow execution?
|
void |
consume()
consume one available unit.
|
void |
consume(long amount)
consume amount available units.
|
long |
getAvailable() |
long |
getLimit() |
abstract long |
getNextRefillTime() |
protected long |
getTimeUnitInMillis() |
boolean |
isBypass() |
void |
set(long limit,
TimeUnit timeUnit)
Set the RateLimiter max available resources and refill period.
|
abstract void |
setNextRefillTime(long nextRefillTime) |
String |
toString() |
void |
update(RateLimiter other)
Sets the current instance of RateLimiter to a new values.
|
long |
waitInterval() |
long |
waitInterval(long amount) |
public static final String QUOTA_RATE_LIMITER_CONF_KEY
public void set(long limit, TimeUnit timeUnit)
limit
- The max value available resource units can be refilled to.timeUnit
- Timeunit factor for translating to ms.public void update(RateLimiter other)
public boolean isBypass()
public long getLimit()
public long getAvailable()
protected long getTimeUnitInMillis()
public boolean canExecute()
public boolean canExecute(long amount)
amount
- the number of required resourcespublic void consume()
public void consume(long amount)
amount
- the number of units to consumepublic long waitInterval()
public long waitInterval(long amount)
public abstract void setNextRefillTime(long nextRefillTime)
public abstract long getNextRefillTime()
Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.