001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.quotas;
019
020import org.apache.yetus.audience.InterfaceAudience;
021import org.apache.yetus.audience.InterfaceStability;
022
023/**
024 * Noop quota limiter returned when no limiter is associated to the user/table
025 */
026@InterfaceAudience.Private
027@InterfaceStability.Evolving
028class NoopQuotaLimiter implements QuotaLimiter {
029  private static QuotaLimiter instance = new NoopQuotaLimiter();
030
031  private NoopQuotaLimiter() {
032    // no-op
033  }
034
035  @Override
036  public void checkQuota(long writeReqs, long estimateWriteSize, long readReqs,
037    long estimateReadSize, long estimateWriteCapacityUnit, long estimateReadCapacityUnit)
038    throws RpcThrottlingException {
039    // no-op
040  }
041
042  @Override
043  public void grabQuota(long writeReqs, long writeSize, long readReqs, long readSize,
044    long writeCapacityUnit, long readCapacityUnit) {
045    // no-op
046  }
047
048  @Override
049  public void consumeWrite(final long size, long capacityUnit) {
050    // no-op
051  }
052
053  @Override
054  public void consumeRead(final long size, long capacityUnit) {
055    // no-op
056  }
057
058  @Override
059  public boolean isBypass() {
060    return true;
061  }
062
063  @Override
064  public long getWriteAvailable() {
065    throw new UnsupportedOperationException();
066  }
067
068  @Override
069  public long getReadAvailable() {
070    throw new UnsupportedOperationException();
071  }
072
073  @Override
074  public String toString() {
075    return "NoopQuotaLimiter";
076  }
077
078  public static QuotaLimiter get() {
079    return instance;
080  }
081}