diff --git a/hbase-shell/src/main/ruby/hbase/quotas.rb b/hbase-shell/src/main/ruby/hbase/quotas.rb index 75757c18fc46..f407abaddc24 100644 --- a/hbase-shell/src/main/ruby/hbase/quotas.rb +++ b/hbase-shell/src/main/ruby/hbase/quotas.rb @@ -366,6 +366,10 @@ def switch_rpc_throttle(enabled) @admin.switchRpcThrottle(java.lang.Boolean.valueOf(enabled)) end + def rpc_throttle_enabled? + @admin.isRpcThrottleEnabled + end + def switch_exceed_throttle_quota(enabled) @admin.exceedThrottleQuotaSwitch(java.lang.Boolean.valueOf(enabled)) end diff --git a/hbase-shell/src/main/ruby/shell.rb b/hbase-shell/src/main/ruby/shell.rb index 6be3854b8a57..c408bf06b227 100644 --- a/hbase-shell/src/main/ruby/shell.rb +++ b/hbase-shell/src/main/ruby/shell.rb @@ -576,6 +576,7 @@ def self.exception_handler(hide_traceback) list_snapshot_sizes enable_rpc_throttle disable_rpc_throttle + rpc_throttle_enabled enable_exceed_throttle_quota disable_exceed_throttle_quota ] diff --git a/hbase-shell/src/main/ruby/shell/commands/rpc_throttle_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/rpc_throttle_enabled.rb new file mode 100644 index 000000000000..0e789f7eadea --- /dev/null +++ b/hbase-shell/src/main/ruby/shell/commands/rpc_throttle_enabled.rb @@ -0,0 +1,42 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +module Shell + module Commands + # Prints whether rpc throttle is enabled + class RpcThrottleEnabled < Command + def help + <<-EOF +Query the current rpc throttle state. +Return true if rpc throttle is enabled, false otherwise. + +Examples: + hbase> rpc_throttle_enabled +EOF + end + + def command + state = quotas_admin.rpc_throttle_enabled? + formatter.row([state.to_s]) + state + end + end + end +end diff --git a/hbase-shell/src/test/ruby/hbase/quotas_test.rb b/hbase-shell/src/test/ruby/hbase/quotas_test.rb index 6e506c52f14a..508749f544f8 100644 --- a/hbase-shell/src/test/ruby/hbase/quotas_test.rb +++ b/hbase-shell/src/test/ruby/hbase/quotas_test.rb @@ -245,15 +245,30 @@ def teardown end define_test 'switch rpc throttle' do + result = nil + output = capture_stdout { result = command(:rpc_throttle_enabled) } + assert(output.include?('true')) + assert(result == true) + result = nil output = capture_stdout { result = command(:disable_rpc_throttle) } assert(output.include?('Previous rpc throttle state : true')) assert(result == true) + result = nil + output = capture_stdout { result = command(:rpc_throttle_enabled) } + assert(output.include?('false')) + assert(result == false) + result = nil output = capture_stdout { result = command(:enable_rpc_throttle) } assert(output.include?('Previous rpc throttle state : false')) assert(result == false) + + result = nil + output = capture_stdout { result = command(:rpc_throttle_enabled) } + assert(output.include?('true')) + assert(result == true) end define_test 'can set and remove region server quota' do