Repository: hbase Updated Branches: refs/heads/branch-2 5ac774089 -> aa8ceb816
HBASE-16191 Add stop_regionserver and stop_master to shell Amending-Author: Peter Somogyi <psomo...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/aa8ceb81 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/aa8ceb81 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/aa8ceb81 Branch: refs/heads/branch-2 Commit: aa8ceb81677dccd9b8f26d328a712873ac76245e Parents: 5ac7740 Author: Enis Soztutar <e...@apache.org> Authored: Fri May 11 14:32:13 2018 +0200 Committer: Peter Somogyi <psomo...@apache.org> Committed: Mon May 14 09:38:22 2018 +0200 ---------------------------------------------------------------------- hbase-shell/src/main/ruby/.rubocop.yml | 5 +++ hbase-shell/src/main/ruby/hbase/admin.rb | 10 +++++ hbase-shell/src/main/ruby/shell.rb | 2 + .../src/main/ruby/shell/commands/stop_master.rb | 38 +++++++++++++++++++ .../ruby/shell/commands/stop_regionserver.rb | 40 ++++++++++++++++++++ 5 files changed, 95 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/aa8ceb81/hbase-shell/src/main/ruby/.rubocop.yml ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/.rubocop.yml b/hbase-shell/src/main/ruby/.rubocop.yml new file mode 100644 index 0000000..7b04138 --- /dev/null +++ b/hbase-shell/src/main/ruby/.rubocop.yml @@ -0,0 +1,5 @@ +Naming/HeredocDelimiterNaming: + Enabled: false + +Layout/IndentHeredoc: + Enabled: false \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hbase/blob/aa8ceb81/hbase-shell/src/main/ruby/hbase/admin.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb index cb57c4c..c385d3d 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 http://git-wip-us.apache.org/repos/asf/hbase/blob/aa8ceb81/hbase-shell/src/main/ruby/shell.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell.rb b/hbase-shell/src/main/ruby/shell.rb index ab07a79..9a79658 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: { http://git-wip-us.apache.org/repos/asf/hbase/blob/aa8ceb81/hbase-shell/src/main/ruby/shell/commands/stop_master.rb ---------------------------------------------------------------------- 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 0000000..45a2b11 --- /dev/null +++ b/hbase-shell/src/main/ruby/shell/commands/stop_master.rb @@ -0,0 +1,38 @@ +# +# +# 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 + # Stop active Master + class StopMaster < Command + def help + <<-EOF +Stop active Master. For experts only. +Examples: + + hbase> stop_master +EOF + end + + def command + admin.stop_master + end + end + end +end http://git-wip-us.apache.org/repos/asf/hbase/blob/aa8ceb81/hbase-shell/src/main/ruby/shell/commands/stop_regionserver.rb ---------------------------------------------------------------------- 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 0000000..127088d --- /dev/null +++ b/hbase-shell/src/main/ruby/shell/commands/stop_regionserver.rb @@ -0,0 +1,40 @@ +# +# +# 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 + # Stop a RegionServer + class StopRegionserver < Command + def help + <<-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