Class DefaultOperationQuota

java.lang.Object
org.apache.hadoop.hbase.quotas.DefaultOperationQuota
All Implemented Interfaces:
OperationQuota
Direct Known Subclasses:
ExceedOperationQuota

@Private @Evolving public class DefaultOperationQuota extends Object implements OperationQuota
  • Field Details

  • 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

      public void checkBatchQuota(int numWrites, int numReads) throws RpcThrottlingException
      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 interface OperationQuota
      Parameters:
      numWrites - number of write operation that will be performed
      numReads - 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 interface OperationQuota
      Parameters:
      scanRequest - the given scan operation
      maxScannerResultSize - the maximum bytes to be returned by the scanner
      maxBlockBytesScanned - the maximum bytes scanned in a single RPC call by the scanner
      prevBlockBytesScannedDifference - the difference between BBS of the previous two next calls
      Throws:
      RpcThrottlingException - if the operation cannot be performed because RPC quota is exceeded.
    • checkQuota

      private void checkQuota(long numWrites, long numReads) throws RpcThrottlingException
      Throws:
      RpcThrottlingException
    • close

      public void close()
      Description copied from interface: OperationQuota
      Cleanup method on operation completion
      Specified by:
      close in interface OperationQuota
    • getReadAvailable

      public long getReadAvailable()
      Description copied from interface: OperationQuota
      Returns the number of bytes available to read to avoid exceeding the quota
      Specified by:
      getReadAvailable in interface OperationQuota
    • getReadConsumed

      public long getReadConsumed()
      Description copied from interface: OperationQuota
      Returns the number of bytes consumed from the quota by the operation
      Specified by:
      getReadConsumed in interface OperationQuota
    • addGetResult

      public void addGetResult(Result result)
      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 interface OperationQuota
    • addScanResult

      public void addScanResult(List<Result> results)
      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 interface OperationQuota
    • addMutation

      public void addMutation(Mutation mutation)
      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 interface OperationQuota
    • updateEstimateConsumeBatchQuota

      protected void updateEstimateConsumeBatchQuota(int numWrites, int numReads)
      Update estimate quota(read/write size/capacityUnits) which will be consumed
      Parameters:
      numWrites - the number of write requests
      numReads - 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 executed
      maxScannerResultSize - the maximum bytes to be returned by the scanner
      maxBlockBytesScanned - the maximum bytes scanned in a single RPC call by the scanner
      prevBlockBytesScannedDifference - 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

      private long estimateConsume(OperationQuota.OperationType type, int numReqs, long avgSize)
    • calculateWriteCapacityUnit

      private long calculateWriteCapacityUnit(long size)
    • calculateReadCapacityUnit

      private long calculateReadCapacityUnit(long size)
    • calculateWriteCapacityUnitDiff

      private long calculateWriteCapacityUnitDiff(long actualSize, long estimateSize)
    • calculateReadCapacityUnitDiff

      private long calculateReadCapacityUnitDiff(long actualSize, long estimateSize)