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    boolean isAtomic, long estimateHandlerThreadUsageMs) 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, boolean isAtomic,
045    long estimateHandlerThreadUsageMs) {
046    // no-op
047  }
048
049  @Override
050  public void consumeWrite(final long size, long capacityUnit, boolean isAtomic) {
051    // no-op
052  }
053
054  @Override
055  public void consumeRead(final long size, long capacityUnit, boolean isAtomic) {
056    // no-op
057  }
058
059  @Override
060  public void consumeTime(final long handlerMillisUsed) {
061    // no-op
062  }
063
064  @Override
065  public boolean isBypass() {
066    return true;
067  }
068
069  @Override
070  public long getWriteAvailable() {
071    throw new UnsupportedOperationException();
072  }
073
074  @Override
075  public long getRequestNumLimit() {
076    return Long.MAX_VALUE;
077  }
078
079  @Override
080  public long getReadNumLimit() {
081    return Long.MAX_VALUE;
082  }
083
084  @Override
085  public long getWriteNumLimit() {
086    return Long.MAX_VALUE;
087  }
088
089  @Override
090  public long getReadAvailable() {
091    throw new UnsupportedOperationException();
092  }
093
094  @Override
095  public long getReadLimit() {
096    return Long.MAX_VALUE;
097  }
098
099  @Override
100  public long getWriteLimit() {
101    return Long.MAX_VALUE;
102  }
103
104  @Override
105  public String toString() {
106    return "NoopQuotaLimiter";
107  }
108
109  public static QuotaLimiter get() {
110    return instance;
111  }
112}