This is an automated email from the ASF dual-hosted git repository.

nihaljain pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.5 by this push:
     new 854921d94fa HBASE-29033 Add a shell command for inspecting the state 
of enable/disable_rpc_throttle (#7448) (#7459)
854921d94fa is described below

commit 854921d94fad62a859026985577534e1e6d7b4e1
Author: Nihal Jain <[email protected]>
AuthorDate: Wed Nov 12 16:15:48 2025 +0530

    HBASE-29033 Add a shell command for inspecting the state of 
enable/disable_rpc_throttle (#7448) (#7459)
    
    Signed-off-by: Nihal Jain <[email protected]>
    Signed-off-by: Pankaj Kumar <[email protected]>
    Reviewed-by: Vaibhav Joshi <[email protected]>
    
    (cherry picked from commit 59bd6b2bef6071748db055828d9799bd122e4042)
    
    Co-authored-by: Liu Xiao <[email protected]>
---
 hbase-shell/src/main/ruby/hbase/quotas.rb          |  4 +++
 hbase-shell/src/main/ruby/shell.rb                 |  1 +
 .../ruby/shell/commands/rpc_throttle_enabled.rb    | 42 ++++++++++++++++++++++
 hbase-shell/src/test/ruby/hbase/quotas_test.rb     | 15 ++++++++
 4 files changed, 62 insertions(+)

diff --git a/hbase-shell/src/main/ruby/hbase/quotas.rb 
b/hbase-shell/src/main/ruby/hbase/quotas.rb
index 3488f0f33db..1749e2d956b 100644
--- a/hbase-shell/src/main/ruby/hbase/quotas.rb
+++ b/hbase-shell/src/main/ruby/hbase/quotas.rb
@@ -375,6 +375,10 @@ module Hbase
       @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 7aa7813e241..6243193f524 100644
--- a/hbase-shell/src/main/ruby/shell.rb
+++ b/hbase-shell/src/main/ruby/shell.rb
@@ -567,6 +567,7 @@ Shell.load_command_group(
     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 00000000000..0e789f7eade
--- /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 6e506c52f14..508749f544f 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 @@ module Hbase
     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

Reply via email to