View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional information regarding
4    * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
7    * law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
8    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
9    * for the specific language governing permissions and limitations under the License.
10   */
11  
12  package org.apache.hadoop.hbase.quotas;
13  
14  import org.apache.hadoop.hbase.classification.InterfaceAudience;
15  import org.apache.hadoop.hbase.classification.InterfaceStability;
16  
17  /**
18   * Noop quota limiter returned when no limiter is associated to the user/table
19   */
20  @InterfaceAudience.Private
21  @InterfaceStability.Evolving
22  final class NoopQuotaLimiter implements QuotaLimiter {
23    private static QuotaLimiter instance = new NoopQuotaLimiter();
24  
25    private NoopQuotaLimiter() {
26      // no-op
27    }
28  
29    @Override
30    public void checkQuota(long writeReqs, long estimateWriteSize, long readReqs,
31        long estimateReadSize, long estimateWriteCapacityUnit, long estimateReadCapacityUnit)
32        throws RpcThrottlingException {
33      // no-op
34    }
35  
36    @Override
37    public void grabQuota(long writeReqs, long writeSize, long readReqs, long readSize,
38        long writeCapacityUnit, long readCapacityUnit) {
39      // no-op
40    }
41  
42    @Override
43    public void consumeWrite(final long size, long capacityUnit) {
44      // no-op
45    }
46  
47    @Override
48    public void consumeRead(final long size, long capacityUnit) {
49      // no-op
50    }
51  
52    @Override
53    public boolean isBypass() {
54      return true;
55    }
56  
57    @Override
58    public long getWriteAvailable() {
59      throw new UnsupportedOperationException();
60    }
61  
62    @Override
63    public long getReadAvailable() {
64      throw new UnsupportedOperationException();
65    }
66  
67    @Override
68    public String toString() {
69      return "NoopQuotaLimiter";
70    }
71  
72    public static QuotaLimiter get() {
73      return instance;
74    }
75  }