From b07e3a537fe1d2490b3dd6f0e05da9ad18ab9137 Mon Sep 17 00:00:00 2001 From: Balazs Meszaros Date: Mon, 29 Jan 2018 16:43:20 +0100 Subject: [PATCH] HBASE-19886 Display maintenance mode in shell, web UI --- .../hbase/tmpl/master/MasterStatusTmpl.jamon | 6 ++++ hbase-shell/src/main/ruby/hbase/admin.rb | 7 ++++ hbase-shell/src/main/ruby/shell.rb | 1 + .../ruby/shell/commands/is_in_maintenance_mode.rb | 37 ++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 hbase-shell/src/main/ruby/shell/commands/is_in_maintenance_mode.rb diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon index 3253a57623..12e0a69b2b 100644 --- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon +++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon @@ -185,6 +185,12 @@ AssignmentManager assignmentManager = master.getAssignmentManager(); re-enabled from the hbase shell by running the command 'catalogjanitor_switch true' + <%if master.isInMaintenanceMode() %> +
+ Your Master is in maintenance mode. This may be because of HBCK aborting while + running in repair mode. Please re-run HBCK in repair mode. +
+ <%if !master.isBalancerOn() %>
The Load Balancer is not enabled which will eventually cause performance degradation diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb index 13b6578aa0..4d340d0e39 100644 --- a/hbase-shell/src/main/ruby/hbase/admin.rb +++ b/hbase-shell/src/main/ruby/hbase/admin.rb @@ -223,6 +223,13 @@ module Hbase @admin.isNormalizerEnabled end + #---------------------------------------------------------------------------------------------- + # Query the current state of master in maintenance mode. + # Returns the state of maintenance mode (true is on). + def is_in_maintenance_mode? + @admin.isMasterInMaintenanceMode + end + #---------------------------------------------------------------------------------------------- # Request a scan of the catalog table (for garbage collection) # Returns an int signifying the number of entries cleaned diff --git a/hbase-shell/src/main/ruby/shell.rb b/hbase-shell/src/main/ruby/shell.rb index 4a74646cc1..507c0a9260 100644 --- a/hbase-shell/src/main/ruby/shell.rb +++ b/hbase-shell/src/main/ruby/shell.rb @@ -336,6 +336,7 @@ Shell.load_command_group( normalize normalizer_switch normalizer_enabled + is_in_maintenance_mode close_region compact flush diff --git a/hbase-shell/src/main/ruby/shell/commands/is_in_maintenance_mode.rb b/hbase-shell/src/main/ruby/shell/commands/is_in_maintenance_mode.rb new file mode 100644 index 0000000000..ad0ed02e3e --- /dev/null +++ b/hbase-shell/src/main/ruby/shell/commands/is_in_maintenance_mode.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 IsInMaintenanceMode < Command + def help + <<-EOF +Is master in maintenance mode? For example: + hbase> is_in_maintenance_mode +EOF + end + + def command + state = admin.is_in_maintenance_mode? + formatter.row([state.to_s]) + state + end + end + end +end -- 2.16.1