Package org.apache.hadoop.hbase.quotas
Class TimeBasedLimiter
java.lang.Object
org.apache.hadoop.hbase.quotas.TimeBasedLimiter
- All Implemented Interfaces:
QuotaLimiter
Simple time based limiter that checks the quota Throttle
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.apache.hadoop.conf.Configuration
private RateLimiter
private RateLimiter
private RateLimiter
private RateLimiter
private RateLimiter
private RateLimiter
private RateLimiter
private RateLimiter
private RateLimiter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkQuota
(long writeReqs, long estimateWriteSize, long readReqs, long estimateReadSize, long estimateWriteCapacityUnit, long estimateReadCapacityUnit) Checks if it is possible to execute the specified operation.void
consumeRead
(long size, long capacityUnit) Removes or add back some read amount to the quota.void
consumeWrite
(long size, long capacityUnit) Removes or add back some write amount to the quota.(package private) static QuotaLimiter
fromThrottle
(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Throttle throttle) long
Returns the number of bytes available to read to avoid exceeding the quotalong
Returns the maximum number of bytes ever available to readlong
Returns the maximum number of reads to allow per TimeUnitlong
Returns the maximum number of requests to allow per TimeUnitlong
Returns the number of bytes available to write to avoid exceeding the quotalong
Returns the maximum number of bytes ever available to writelong
Returns the maximum number of writes to allow per TimeUnitvoid
grabQuota
(long writeReqs, long writeSize, long readReqs, long readSize, long writeCapacityUnit, long readCapacityUnit) Removes the specified write and read amount from the quota.boolean
isBypass()
Returns true if the limiter is a noopprivate static void
setFromTimedQuota
(RateLimiter limiter, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota timedQuota) toString()
void
update
(TimeBasedLimiter other)
-
Field Details
-
conf
-
reqsLimiter
-
reqSizeLimiter
-
writeReqsLimiter
-
writeSizeLimiter
-
readReqsLimiter
-
readSizeLimiter
-
reqCapacityUnitLimiter
-
writeCapacityUnitLimiter
-
readCapacityUnitLimiter
-
-
Constructor Details
-
TimeBasedLimiter
private TimeBasedLimiter()
-
-
Method Details
-
fromThrottle
static QuotaLimiter fromThrottle(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Throttle throttle) -
update
-
setFromTimedQuota
private static void setFromTimedQuota(RateLimiter limiter, org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.TimedQuota timedQuota) -
checkQuota
public void checkQuota(long writeReqs, long estimateWriteSize, long readReqs, long estimateReadSize, long estimateWriteCapacityUnit, long estimateReadCapacityUnit) throws RpcThrottlingException Description copied from interface:QuotaLimiter
Checks if it is possible to execute the specified operation.- Specified by:
checkQuota
in interfaceQuotaLimiter
- Parameters:
writeReqs
- the write requests that will be checked against the available quotaestimateWriteSize
- the write size that will be checked against the available quotareadReqs
- the read requests that will be checked against the available quotaestimateReadSize
- the read size that will be checked against the available quotaestimateWriteCapacityUnit
- the write capacity unit that will be checked against the available quotaestimateReadCapacityUnit
- the read capacity unit that will be checked against the available quota- Throws:
RpcThrottlingException
- thrown if not enough available resources to perform operation.
-
grabQuota
public void grabQuota(long writeReqs, long writeSize, long readReqs, long readSize, long writeCapacityUnit, long readCapacityUnit) Description copied from interface:QuotaLimiter
Removes the specified write and read amount from the quota. At this point the write and read amount will be an estimate, that will be later adjusted with a consumeWrite()/consumeRead() call.- Specified by:
grabQuota
in interfaceQuotaLimiter
- Parameters:
writeReqs
- the write requests that will be removed from the current quotawriteSize
- the write size that will be removed from the current quotareadReqs
- the read requests that will be removed from the current quotareadSize
- the read size that will be removed from the current quotawriteCapacityUnit
- the write capacity unit that will be removed from the current quotareadCapacityUnit
- the read capacity unit num that will be removed from the current quota
-
consumeWrite
Description copied from interface:QuotaLimiter
Removes or add back some write amount to the quota. (called at the end of an operation in case the estimate quota was off)- Specified by:
consumeWrite
in interfaceQuotaLimiter
-
consumeRead
Description copied from interface:QuotaLimiter
Removes or add back some read amount to the quota. (called at the end of an operation in case the estimate quota was off)- Specified by:
consumeRead
in interfaceQuotaLimiter
-
isBypass
Description copied from interface:QuotaLimiter
Returns true if the limiter is a noop- Specified by:
isBypass
in interfaceQuotaLimiter
-
getWriteAvailable
Description copied from interface:QuotaLimiter
Returns the number of bytes available to write to avoid exceeding the quota- Specified by:
getWriteAvailable
in interfaceQuotaLimiter
-
getRequestNumLimit
Description copied from interface:QuotaLimiter
Returns the maximum number of requests to allow per TimeUnit- Specified by:
getRequestNumLimit
in interfaceQuotaLimiter
-
getReadNumLimit
Description copied from interface:QuotaLimiter
Returns the maximum number of reads to allow per TimeUnit- Specified by:
getReadNumLimit
in interfaceQuotaLimiter
-
getWriteNumLimit
Description copied from interface:QuotaLimiter
Returns the maximum number of writes to allow per TimeUnit- Specified by:
getWriteNumLimit
in interfaceQuotaLimiter
-
getReadAvailable
Description copied from interface:QuotaLimiter
Returns the number of bytes available to read to avoid exceeding the quota- Specified by:
getReadAvailable
in interfaceQuotaLimiter
-
getReadLimit
Description copied from interface:QuotaLimiter
Returns the maximum number of bytes ever available to read- Specified by:
getReadLimit
in interfaceQuotaLimiter
-
getWriteLimit
Description copied from interface:QuotaLimiter
Returns the maximum number of bytes ever available to write- Specified by:
getWriteLimit
in interfaceQuotaLimiter
-
toString
-