@Override
  public OperationQuota checkScanQuota(final Region region,
    final ClientProtos.ScanRequest scanRequest, long maxScannerResultSize,
    long maxBlockBytesScanned, long prevBlockBytesScannedDifference)
    throws IOException, RpcThrottlingException {
    Optional<User> user = RpcServer.getRequestUser();
    UserGroupInformation ugi;
    if (user.isPresent()) {
      ugi = user.get().getUGI();
    } else {
      ugi = User.getCurrent().getUGI();
    }
    TableDescriptor tableDescriptor = region.getTableDescriptor();
    TableName table = tableDescriptor.getTableName();

    OperationQuota quota = getQuota(ugi, table, region.getMinBlockSizeBytes());
    try {
      quota.checkScanQuota(scanRequest, maxScannerResultSize, maxBlockBytesScanned,
        prevBlockBytesScannedDifference);
    } catch (RpcThrottlingException e) {
      LOG.debug("Throttling exception for user=" + ugi.getUserName() + " table=" + table + " scan="
        + scanRequest.getScannerId() + ": " + e.getMessage());
      throw e;
    }
    return quota;
  }
Returns the quota for an operation.
@param ugi   the user that is executing the operation
@param table the table where the operation will be executed
@return the OperationQuota
hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/RegionServerRpcQuotaManager.java