From c407035df4aef1ef52ec1f78e307dc5a4748ee8e Mon Sep 17 00:00:00 2001 From: Enis Soztutar Date: Fri, 11 May 2018 14:32:13 +0200 Subject: [PATCH] HBASE-16191 Add stop_regionserver and stop_master to shell Amending-Author: Peter Somogyi --- hbase-shell/src/main/ruby/hbase/admin.rb | 10 +++++ hbase-shell/src/main/ruby/shell.rb | 2 + .../main/ruby/shell/commands/stop_master.rb | 37 ++++++++++++++++++ .../ruby/shell/commands/stop_regionserver.rb | 39 +++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 hbase-shell/src/main/ruby/shell/commands/stop_master.rb create mode 100644 hbase-shell/src/main/ruby/shell/commands/stop_regionserver.rb diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb index cb57c4cf97..d5631dff77 100644 --- a/hbase-shell/src/main/ruby/hbase/admin.rb +++ b/hbase-shell/src/main/ruby/hbase/admin.rb @@ -1309,6 +1309,16 @@ module Hbase TableName.valueOf(new_table_name), preserve_splits) end + + # Stop the active Master + def stop_master() + @admin.stopMaster() + end + + # Stop the given RegionServer + def stop_regionserver(hostport) + @admin.stopRegionServer(hostport) + end end # rubocop:enable Metrics/ClassLength end diff --git a/hbase-shell/src/main/ruby/shell.rb b/hbase-shell/src/main/ruby/shell.rb index ab07a79b98..9a796587b6 100644 --- a/hbase-shell/src/main/ruby/shell.rb +++ b/hbase-shell/src/main/ruby/shell.rb @@ -357,6 +357,8 @@ Shell.load_command_group( list_deadservers clear_deadservers clear_block_cache + stop_master + stop_regionserver ], # TODO: remove older hlog_roll command aliases: { diff --git a/hbase-shell/src/main/ruby/shell/commands/stop_master.rb b/hbase-shell/src/main/ruby/shell/commands/stop_master.rb new file mode 100644 index 0000000000..4597916695 --- /dev/null +++ b/hbase-shell/src/main/ruby/shell/commands/stop_master.rb @@ -0,0 +1,37 @@ +# +# +# 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 + class StopMaster < Command + def help + return <<-EOF +Stop active Master. For experts only. +Examples: + + hbase> stop_master +EOF + end + + def command() + admin.stop_master() + end + end + end +end \ No newline at end of file diff --git a/hbase-shell/src/main/ruby/shell/commands/stop_regionserver.rb b/hbase-shell/src/main/ruby/shell/commands/stop_regionserver.rb new file mode 100644 index 0000000000..d22f8612d8 --- /dev/null +++ b/hbase-shell/src/main/ruby/shell/commands/stop_regionserver.rb @@ -0,0 +1,39 @@ +# +# +# 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 + class StopRegionserver < Command + def help + return <<-EOF +Stop a RegionServer. For experts only. +Consider using graceful_stop.sh script instead! + +Examples: + + hbase> stop_regionserver 'hostname:port' +EOF + end + + def command(hostport) + admin.stop_regionserver(hostport) + end + end + end +end -- 2.17.0