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 getRequestNumLimit() { 070 return Long.MAX_VALUE; 071 } 072 073 @Override 074 public long getReadNumLimit() { 075 return Long.MAX_VALUE; 076 } 077 078 @Override 079 public long getWriteNumLimit() { 080 return Long.MAX_VALUE; 081 } 082 083 @Override 084 public long getReadAvailable() { 085 throw new UnsupportedOperationException(); 086 } 087 088 @Override 089 public long getReadLimit() { 090 return Long.MAX_VALUE; 091 } 092 093 @Override 094 public long getWriteLimit() { 095 return Long.MAX_VALUE; 096 } 097 098 @Override 099 public String toString() { 100 return "NoopQuotaLimiter"; 101 } 102 103 public static QuotaLimiter get() { 104 return instance; 105 } 106}