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
Modifier and TypeFieldDescriptionprivate long
protected final List<QuotaLimiter>
private static final double
private long
private final long[]
protected long
private final long
protected long
protected long
protected long
protected long
private boolean
private final long
protected long
protected long
protected long
protected long
Fields inherited from interface org.apache.hadoop.hbase.quotas.OperationQuota
USE_RESULT_SIZE_BYTES, USE_RESULT_SIZE_BYTES_DEFAULT
-
Constructor Summary
ConstructorDescriptionDefaultOperationQuota
(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 TypeMethodDescriptionvoid
addGetResult
(Result result) Add a get result.void
addMutation
(Mutation mutation) Add a mutation result.void
addScanResult
(List<Result> results) Add a scan result.private long
calculateReadCapacityUnit
(long size) private long
calculateReadCapacityUnitDiff
(long actualSize, long estimateSize) private long
calculateWriteCapacityUnit
(long size) private long
calculateWriteCapacityUnitDiff
(long actualSize, long estimateSize) void
checkBatchQuota
(int numWrites, int numReads) Checks if it is possible to execute the specified operation.private void
checkQuota
(long numWrites, long numReads) void
checkScanQuota
(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.void
close()
Cleanup method on operation completionprivate long
estimateConsume
(OperationQuota.OperationType type, int numReqs, long avgSize) long
Returns the number of bytes available to read to avoid exceeding the quotalong
Returns the number of bytes consumed from the quota by the operationprotected static long
getScanReadConsumeEstimate
(long blockSizeBytes, long nextCallSeq, long maxScannerResultSize, long maxBlockBytesScanned, long prevBlockBytesScannedDifference) protected void
updateEstimateConsumeBatchQuota
(int numWrites, int numReads) Update estimate quota(read/write size/capacityUnits) which will be consumedprotected 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 consumedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:OperationQuota
Checks 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:
checkBatchQuota
in 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:OperationQuota
Checks if it is possible to execute the scan. The quota will be estimated based on the composition of the scan.- Specified by:
checkScanQuota
in 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:OperationQuota
Cleanup method on operation completion- Specified by:
close
in interfaceOperationQuota
-
getReadAvailable
Description copied from interface:OperationQuota
Returns the number of bytes available to read to avoid exceeding the quota- Specified by:
getReadAvailable
in interfaceOperationQuota
-
getReadConsumed
Description copied from interface:OperationQuota
Returns the number of bytes consumed from the quota by the operation- Specified by:
getReadConsumed
in interfaceOperationQuota
-
addGetResult
Description copied from interface:OperationQuota
Add 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:
addGetResult
in interfaceOperationQuota
-
addScanResult
Description copied from interface:OperationQuota
Add 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:
addScanResult
in interfaceOperationQuota
-
addMutation
Description copied from interface:OperationQuota
Add 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:
addMutation
in 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
-