Skip to content

Commit 26f3775

Browse files
liuxiaocs7NihalJain
authored andcommitted
HBASE-29033 Add a shell command for inspecting the state of enable/disable_rpc_throttle (#7448)
Signed-off-by: Nihal Jain <nihaljain@apache.org> Signed-off-by: Pankaj Kumar <pankajkumar@apache.org> Reviewed-by: Vaibhav Joshi <vjoshi@cloudera.com> (cherry picked from commit 59bd6b2)
1 parent 4ea77a0 commit 26f3775

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

hbase-shell/src/main/ruby/hbase/quotas.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,10 @@ def switch_rpc_throttle(enabled)
375375
@admin.switchRpcThrottle(java.lang.Boolean.valueOf(enabled))
376376
end
377377

378+
def rpc_throttle_enabled?
379+
@admin.isRpcThrottleEnabled
380+
end
381+
378382
def switch_exceed_throttle_quota(enabled)
379383
@admin.exceedThrottleQuotaSwitch(java.lang.Boolean.valueOf(enabled))
380384
end

hbase-shell/src/main/ruby/shell.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ def self.exception_handler(hide_traceback)
574574
list_snapshot_sizes
575575
enable_rpc_throttle
576576
disable_rpc_throttle
577+
rpc_throttle_enabled
577578
enable_exceed_throttle_quota
578579
disable_exceed_throttle_quota
579580
]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
21+
module Shell
22+
module Commands
23+
# Prints whether rpc throttle is enabled
24+
class RpcThrottleEnabled < Command
25+
def help
26+
<<-EOF
27+
Query the current rpc throttle state.
28+
Return true if rpc throttle is enabled, false otherwise.
29+
30+
Examples:
31+
hbase> rpc_throttle_enabled
32+
EOF
33+
end
34+
35+
def command
36+
state = quotas_admin.rpc_throttle_enabled?
37+
formatter.row([state.to_s])
38+
state
39+
end
40+
end
41+
end
42+
end

hbase-shell/src/test/ruby/hbase/quotas_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,30 @@ def teardown
245245
end
246246

247247
define_test 'switch rpc throttle' do
248+
result = nil
249+
output = capture_stdout { result = command(:rpc_throttle_enabled) }
250+
assert(output.include?('true'))
251+
assert(result == true)
252+
248253
result = nil
249254
output = capture_stdout { result = command(:disable_rpc_throttle) }
250255
assert(output.include?('Previous rpc throttle state : true'))
251256
assert(result == true)
252257

258+
result = nil
259+
output = capture_stdout { result = command(:rpc_throttle_enabled) }
260+
assert(output.include?('false'))
261+
assert(result == false)
262+
253263
result = nil
254264
output = capture_stdout { result = command(:enable_rpc_throttle) }
255265
assert(output.include?('Previous rpc throttle state : false'))
256266
assert(result == false)
267+
268+
result = nil
269+
output = capture_stdout { result = command(:rpc_throttle_enabled) }
270+
assert(output.include?('true'))
271+
assert(result == true)
257272
end
258273

259274
define_test 'can set and remove region server quota' do

0 commit comments

Comments
 (0)