

package org.apache.hadoop.hbase.quotas;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hbase.client.Mutation;
import org.apache.hadoop.hbase.client.Result;

/**
 * Noop operation quota returned when no quota is associated to the user/table
 */
@InterfaceAudience.Private
@InterfaceStability.Evolving
class NoopOperationQuota implements OperationQuota {
  private static OperationQuota instance = new NoopOperationQuota();

  private NoopOperationQuota() {
    // no-op
  }

  public static OperationQuota get() {
    return instance;
  }

  @Override
  public void checkQuota(int numWrites, int numReads, int numScans)
      throws ThrottlingException {
    // no-op
  }

  @Override
  public void close() {
    // no-op
  }

  @Override
  public void addGetResult(final Result result) {
    // no-op
  }

  @Override
  public void addScanResult(final List<Result> results) {
    // no-op
  }

  @Override
  public void addMutation(final Mutation mutation) {
    // no-op
  }

  @Override
  public long getReadAvailable() {
    return Long.MAX_VALUE;
  }

  @Override
  public long getWriteAvailable() {
    return Long.MAX_VALUE;
  }

  @Override
  public long getAvgOperationSize(OperationType type) {
    return -1;
  }
}
