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  import org.apache.hadoop.hbase.quotas.OperationQuota.OperationType;
17  
18  /**
19   * Noop quota limiter returned when no limiter is associated to the user/table
20   */
21  @InterfaceAudience.Private
22  @InterfaceStability.Evolving
23  final class NoopQuotaLimiter implements QuotaLimiter {
24    private static QuotaLimiter instance = new NoopQuotaLimiter();
25  
26    private NoopQuotaLimiter() {
27      // no-op
28    }
29  
30    @Override
31    public void checkQuota(long writeReqs, long estimateWriteSize, long readReqs,
32        long estimateReadSize) throws ThrottlingException {
33      // no-op
34    }
35  
36    @Override
37    public void grabQuota(long writeReqs, long writeSize, long readReqs, long readSize) {
38      // no-op
39    }
40  
41    @Override
42    public void consumeWrite(final long size) {
43      // no-op
44    }
45  
46    @Override
47    public void consumeRead(final long size) {
48      // no-op
49    }
50  
51    @Override
52    public boolean isBypass() {
53      return true;
54    }
55  
56    @Override
57    public long getWriteAvailable() {
58      throw new UnsupportedOperationException();
59    }
60  
61    @Override
62    public long getReadAvailable() {
63      throw new UnsupportedOperationException();
64    }
65  
66    @Override
67    public String toString() {
68      return "NoopQuotaLimiter";
69    }
70  
71    public static QuotaLimiter get() {
72      return instance;
73    }
74  }