Class TimeBasedLimiter

java.lang.Object
org.apache.hadoop.hbase.quotas.TimeBasedLimiter
All Implemented Interfaces:
QuotaLimiter

@Private @Evolving public class TimeBasedLimiter extends Object implements QuotaLimiter
Simple time based limiter that checks the quota Throttle
  • Field Details

  • Constructor Details

  • Method Details

    • fromThrottle

      static QuotaLimiter fromThrottle(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Throttle throttle)
    • update

      public void update(TimeBasedLimiter other)
    • 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 interface QuotaLimiter
      Parameters:
      writeReqs - the write requests that will be checked against the available quota
      estimateWriteSize - the write size that will be checked against the available quota
      readReqs - the read requests that will be checked against the available quota
      estimateReadSize - the read size that will be checked against the available quota
      estimateWriteCapacityUnit - the write capacity unit that will be checked against the available quota
      estimateReadCapacityUnit - 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 interface QuotaLimiter
      Parameters:
      writeReqs - the write requests that will be removed from the current quota
      writeSize - the write size that will be removed from the current quota
      readReqs - the read requests that will be removed from the current quota
      readSize - the read size that will be removed from the current quota
      writeCapacityUnit - the write capacity unit that will be removed from the current quota
      readCapacityUnit - the read capacity unit num that will be removed from the current quota
    • consumeWrite

      public void consumeWrite(long size, long capacityUnit)
      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 interface QuotaLimiter
    • consumeRead

      public void consumeRead(long size, long capacityUnit)
      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 interface QuotaLimiter
    • isBypass

      public boolean isBypass()
      Description copied from interface: QuotaLimiter
      Returns true if the limiter is a noop
      Specified by:
      isBypass in interface QuotaLimiter
    • getWriteAvailable

      public long getWriteAvailable()
      Description copied from interface: QuotaLimiter
      Returns the number of bytes available to write to avoid exceeding the quota
      Specified by:
      getWriteAvailable in interface QuotaLimiter
    • getRequestNumLimit

      public long getRequestNumLimit()
      Description copied from interface: QuotaLimiter
      Returns the maximum number of requests to allow per TimeUnit
      Specified by:
      getRequestNumLimit in interface QuotaLimiter
    • getReadNumLimit

      public long getReadNumLimit()
      Description copied from interface: QuotaLimiter
      Returns the maximum number of reads to allow per TimeUnit
      Specified by:
      getReadNumLimit in interface QuotaLimiter
    • getWriteNumLimit

      public long getWriteNumLimit()
      Description copied from interface: QuotaLimiter
      Returns the maximum number of writes to allow per TimeUnit
      Specified by:
      getWriteNumLimit in interface QuotaLimiter
    • getReadAvailable

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

      public long getReadLimit()
      Description copied from interface: QuotaLimiter
      Returns the maximum number of bytes ever available to read
      Specified by:
      getReadLimit in interface QuotaLimiter
    • getWriteLimit

      public long getWriteLimit()
      Description copied from interface: QuotaLimiter
      Returns the maximum number of bytes ever available to write
      Specified by:
      getWriteLimit in interface QuotaLimiter
    • toString

      public String toString()
      Overrides:
      toString in class Object