Package org.apache.hadoop.hbase.quotas
Class DefaultOperationQuota
java.lang.Object
org.apache.hadoop.hbase.quotas.DefaultOperationQuota
- All Implemented Interfaces:
OperationQuota
- Direct Known Subclasses:
ExceedOperationQuota
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.quotas.OperationQuota
OperationQuota.OperationType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprotected final List<QuotaLimiter>private static final doubleprivate longprivate final long[]protected longprivate final longprotected longprotected longprotected longprotected longprivate booleanprivate final longprotected longprotected longprotected longprotected longFields inherited from interface org.apache.hadoop.hbase.quotas.OperationQuota
USE_RESULT_SIZE_BYTES, USE_RESULT_SIZE_BYTES_DEFAULT -
Constructor Summary
ConstructorsConstructorDescriptionDefaultOperationQuota(org.apache.hadoop.conf.Configuration conf, int blockSizeBytes, QuotaLimiter... limiters) DefaultOperationQuota(org.apache.hadoop.conf.Configuration conf, List<QuotaLimiter> limiters) NOTE: The order matters. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGetResult(Result result) Add a get result.voidaddMutation(Mutation mutation) Add a mutation result.voidaddScanResult(List<Result> results) Add a scan result.private longcalculateReadCapacityUnit(long size) private longcalculateReadCapacityUnitDiff(long actualSize, long estimateSize) private longcalculateWriteCapacityUnit(long size) private longcalculateWriteCapacityUnitDiff(long actualSize, long estimateSize) voidcheckBatchQuota(int numWrites, int numReads) Checks if it is possible to execute the specified operation.private voidcheckQuota(long numWrites, long numReads) voidcheckScanQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest scanRequest, long maxScannerResultSize, long maxBlockBytesScanned, long prevBlockBytesScannedDifference) Checks if it is possible to execute the scan.voidclose()Cleanup method on operation completionprivate longestimateConsume(OperationQuota.OperationType type, int numReqs, long avgSize) longReturns the number of bytes available to read to avoid exceeding the quotalongReturns the number of bytes consumed from the quota by the operationprotected static longgetScanReadConsumeEstimate(long blockSizeBytes, long nextCallSeq, long maxScannerResultSize, long maxBlockBytesScanned, long prevBlockBytesScannedDifference) protected voidupdateEstimateConsumeBatchQuota(int numWrites, int numReads) Update estimate quota(read/write size/capacityUnits) which will be consumedprotected voidupdateEstimateConsumeScanQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest scanRequest, long maxScannerResultSize, long maxBlockBytesScanned, long prevBlockBytesScannedDifference) Update estimate quota(read/write size/capacityUnits) which will be consumedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.quotas.OperationQuota
getMaxResultSize
-
Field Details
-
MAX_SCAN_ESTIMATE_PROPORTIONAL_LIMIT_CONSUMPTION
- See Also:
-
limiters
-
writeCapacityUnit
-
readCapacityUnit
-
readAvailable
-
writeConsumed
-
readConsumed
-
writeCapacityUnitConsumed
-
readCapacityUnitConsumed
-
operationSize
-
writeDiff
-
readDiff
-
writeCapacityUnitDiff
-
readCapacityUnitDiff
-
useResultSizeBytes
-
blockSizeBytes
-
maxScanEstimate
-
-
Constructor Details
-
DefaultOperationQuota
public DefaultOperationQuota(org.apache.hadoop.conf.Configuration conf, int blockSizeBytes, QuotaLimiter... limiters) -
DefaultOperationQuota
public DefaultOperationQuota(org.apache.hadoop.conf.Configuration conf, List<QuotaLimiter> limiters) NOTE: The order matters. It should be something like [user, table, namespace, global]
-
-
Method Details
-
checkBatchQuota
Description copied from interface:OperationQuotaChecks if it is possible to execute the specified operation. The quota will be estimated based on the number of operations to perform and the average size accumulated during time.- Specified by:
checkBatchQuotain interfaceOperationQuota- Parameters:
numWrites- number of write operation that will be performednumReads- number of small-read operation that will be performed- Throws:
RpcThrottlingException- if the operation cannot be performed because RPC quota is exceeded.
-
checkScanQuota
public void checkScanQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest scanRequest, long maxScannerResultSize, long maxBlockBytesScanned, long prevBlockBytesScannedDifference) throws RpcThrottlingException Description copied from interface:OperationQuotaChecks if it is possible to execute the scan. The quota will be estimated based on the composition of the scan.- Specified by:
checkScanQuotain interfaceOperationQuota- Parameters:
scanRequest- the given scan operationmaxScannerResultSize- the maximum bytes to be returned by the scannermaxBlockBytesScanned- the maximum bytes scanned in a single RPC call by the scannerprevBlockBytesScannedDifference- the difference between BBS of the previous two next calls- Throws:
RpcThrottlingException- if the operation cannot be performed because RPC quota is exceeded.
-
checkQuota
- Throws:
RpcThrottlingException
-
close
Description copied from interface:OperationQuotaCleanup method on operation completion- Specified by:
closein interfaceOperationQuota
-
getReadAvailable
Description copied from interface:OperationQuotaReturns the number of bytes available to read to avoid exceeding the quota- Specified by:
getReadAvailablein interfaceOperationQuota
-
getReadConsumed
Description copied from interface:OperationQuotaReturns the number of bytes consumed from the quota by the operation- Specified by:
getReadConsumedin interfaceOperationQuota
-
addGetResult
Description copied from interface:OperationQuotaAdd a get result. This will be used to calculate the exact quota and have a better short-read average size for the next time.- Specified by:
addGetResultin interfaceOperationQuota
-
addScanResult
Description copied from interface:OperationQuotaAdd a scan result. This will be used to calculate the exact quota and have a better long-read average size for the next time.- Specified by:
addScanResultin interfaceOperationQuota
-
addMutation
Description copied from interface:OperationQuotaAdd a mutation result. This will be used to calculate the exact quota and have a better mutation average size for the next time.- Specified by:
addMutationin interfaceOperationQuota
-
updateEstimateConsumeBatchQuota
Update estimate quota(read/write size/capacityUnits) which will be consumed- Parameters:
numWrites- the number of write requestsnumReads- the number of read requests
-
updateEstimateConsumeScanQuota
protected void updateEstimateConsumeScanQuota(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest scanRequest, long maxScannerResultSize, long maxBlockBytesScanned, long prevBlockBytesScannedDifference) Update estimate quota(read/write size/capacityUnits) which will be consumed- Parameters:
scanRequest- the scan to be executedmaxScannerResultSize- the maximum bytes to be returned by the scannermaxBlockBytesScanned- the maximum bytes scanned in a single RPC call by the scannerprevBlockBytesScannedDifference- the difference between BBS of the previous two next calls
-
getScanReadConsumeEstimate
protected static long getScanReadConsumeEstimate(long blockSizeBytes, long nextCallSeq, long maxScannerResultSize, long maxBlockBytesScanned, long prevBlockBytesScannedDifference) -
estimateConsume
-
calculateWriteCapacityUnit
-
calculateReadCapacityUnit
-
calculateWriteCapacityUnitDiff
-
calculateReadCapacityUnitDiff
-