@InterfaceAudience.Private @InterfaceStability.Evolving public class TimeBasedLimiter extends Object implements QuotaLimiter
| Modifier and Type | Method and Description |
|---|---|
void |
addOperationSize(OperationQuota.OperationType type,
long size)
Add the average size of the specified operation type.
|
void |
checkQuota(long writeSize,
long readSize)
Checks if it is possible to execute the specified operation.
|
void |
consumeRead(long size)
Removes or add back some read amount to the quota.
|
void |
consumeWrite(long size)
Removes or add back some write amount to the quota.
|
long |
getAvgOperationSize(OperationQuota.OperationType type) |
long |
getReadAvailable() |
long |
getWriteAvailable() |
void |
grabQuota(long writeSize,
long readSize)
Removes the specified write and read amount from the quota.
|
boolean |
isBypass() |
String |
toString() |
void |
update(TimeBasedLimiter other) |
public void update(TimeBasedLimiter other)
public void checkQuota(long writeSize,
long readSize)
throws ThrottlingException
QuotaLimitercheckQuota in interface QuotaLimiterwriteSize - the write size that will be checked against the available quotareadSize - the read size that will be checked against the available quotaThrottlingException - thrown if not enough avialable resources to perform operation.public void grabQuota(long writeSize,
long readSize)
QuotaLimitergrabQuota in interface QuotaLimiterwriteSize - the write size that will be removed from the current quotareadSize - the read size that will be removed from the current quotapublic void consumeWrite(long size)
QuotaLimiterconsumeWrite in interface QuotaLimiterpublic void consumeRead(long size)
QuotaLimiterconsumeRead in interface QuotaLimiterpublic boolean isBypass()
isBypass in interface QuotaLimiterpublic long getWriteAvailable()
getWriteAvailable in interface QuotaLimiterpublic long getReadAvailable()
getReadAvailable in interface QuotaLimiterpublic void addOperationSize(OperationQuota.OperationType type, long size)
QuotaLimiteraddOperationSize in interface QuotaLimiterpublic long getAvgOperationSize(OperationQuota.OperationType type)
getAvgOperationSize in interface QuotaLimiterCopyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.