Interface QuotaLimiter

All Known Implementing Classes:
NoopQuotaLimiter, TimeBasedLimiter

@Private @Evolving public interface QuotaLimiter
Internal interface used to interact with the user/table quota.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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.
    long
    Returns the number of bytes available to read to avoid exceeding the quota
    long
    Returns the maximum number of bytes ever available to read
    long
    Returns the maximum number of reads to allow per TimeUnit
    long
    Returns the maximum number of requests to allow per TimeUnit
    long
    Returns the number of bytes available to write to avoid exceeding the quota
    long
    Returns the maximum number of bytes ever available to write
    long
    Returns the maximum number of writes to allow per TimeUnit
    void
    grabQuota(long writeReqs, long writeSize, long readReqs, long readSize, long writeCapacityUnit, long readCapacityUnit)
    Removes the specified write and read amount from the quota.
    boolean
    Returns true if the limiter is a noop
  • Method Details

    • checkQuota

      void checkQuota(long writeReqs, long estimateWriteSize, long readReqs, long estimateReadSize, long estimateWriteCapacityUnit, long estimateReadCapacityUnit) throws RpcThrottlingException
      Checks if it is possible to execute the specified operation.
      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

      void grabQuota(long writeReqs, long writeSize, long readReqs, long readSize, long writeCapacityUnit, long readCapacityUnit)
      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.
      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

      void consumeWrite(long size, long capacityUnit)
      Removes or add back some write amount to the quota. (called at the end of an operation in case the estimate quota was off)
    • consumeRead

      void consumeRead(long size, long capacityUnit)
      Removes or add back some read amount to the quota. (called at the end of an operation in case the estimate quota was off)
    • isBypass

      boolean isBypass()
      Returns true if the limiter is a noop
    • getReadAvailable

      Returns the number of bytes available to read to avoid exceeding the quota
    • getReadLimit

      long getReadLimit()
      Returns the maximum number of bytes ever available to read
    • getWriteLimit

      Returns the maximum number of bytes ever available to write
    • getWriteAvailable

      Returns the number of bytes available to write to avoid exceeding the quota
    • getRequestNumLimit

      Returns the maximum number of requests to allow per TimeUnit
    • getReadNumLimit

      Returns the maximum number of reads to allow per TimeUnit
    • getWriteNumLimit

      Returns the maximum number of writes to allow per TimeUnit