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 estimateWriteSize, long estimateReadSize) throws ThrottlingException {
32      // no-op
33    }
34  
35    @Override
36    public void grabQuota(long writeSize, long readSize) {
37      // no-op
38    }
39  
40    @Override
41    public void consumeWrite(final long size) {
42      // no-op
43    }
44  
45    @Override
46    public void consumeRead(final long size) {
47      // no-op
48    }
49  
50    @Override
51    public boolean isBypass() {
52      return true;
53    }
54  
55    @Override
56    public long getWriteAvailable() {
57      throw new UnsupportedOperationException();
58    }
59  
60    @Override
61    public long getReadAvailable() {
62      throw new UnsupportedOperationException();
63    }
64  
65    @Override
66    public void addOperationSize(OperationType type, long size) {
67    }
68  
69    @Override
70    public long getAvgOperationSize(OperationType type) {
71      return -1;
72    }
73  
74    @Override
75    public String toString() {
76      return "NoopQuotaLimiter";
77    }
78  
79    public static QuotaLimiter get() {
80      return instance;
81    }
82  }