Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions hbase-shell/src/main/ruby/hbase/quotas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,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
Expand Down
1 change: 1 addition & 0 deletions hbase-shell/src/main/ruby/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,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
]
Expand Down
42 changes: 42 additions & 0 deletions hbase-shell/src/main/ruby/shell/commands/rpc_throttle_enabled.rb
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions hbase-shell/src/test/ruby/hbase/quotas_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down