HBASE-20670 NPE in HMaster#isInMaintenanceMode
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a45763df Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a45763df Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a45763df Branch: refs/heads/master Commit: a45763df553edd006c2168df3a64f0f2cdf2366f Parents: 832f67d Author: Andrew Purtell <apurt...@apache.org> Authored: Fri Jun 1 15:22:18 2018 -0700 Committer: Andrew Purtell <apurt...@apache.org> Committed: Mon Jun 4 15:19:47 2018 -0700 ---------------------------------------------------------------------- .../org/apache/hadoop/hbase/master/HMaster.java | 25 ++++++++++++++++---- .../hadoop/hbase/master/MasterRpcServices.java | 6 ++++- .../hadoop/hbase/master/MasterServices.java | 3 ++- 3 files changed, 27 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/a45763df/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index b565963..0871482 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -2822,7 +2822,10 @@ public class HMaster extends HRegionServer implements MasterServices { * @return true if master is in maintenanceMode */ @Override - public boolean isInMaintenanceMode() { + public boolean isInMaintenanceMode() throws IOException { + if (!isInitialized()) { + throw new PleaseHoldException("Master is initializing"); + } return maintenanceModeTracker.isInMaintenanceMode(); } @@ -3359,7 +3362,11 @@ public class HMaster extends HRegionServer implements MasterServices { * @return The state of the load balancer, or false if the load balancer isn't defined. */ public boolean isBalancerOn() { - if (null == loadBalancerTracker || isInMaintenanceMode()) { + try { + if (null == loadBalancerTracker || isInMaintenanceMode()) { + return false; + } + } catch (IOException e) { return false; } return loadBalancerTracker.isBalancerOn(); @@ -3370,8 +3377,12 @@ public class HMaster extends HRegionServer implements MasterServices { * false is returned. */ public boolean isNormalizerOn() { - return (null == regionNormalizerTracker || isInMaintenanceMode()) ? - false: regionNormalizerTracker.isNormalizerOn(); + try { + return (null == regionNormalizerTracker || isInMaintenanceMode()) ? + false: regionNormalizerTracker.isNormalizerOn(); + } catch (IOException e) { + return false; + } } /** @@ -3382,7 +3393,11 @@ public class HMaster extends HRegionServer implements MasterServices { */ @Override public boolean isSplitOrMergeEnabled(MasterSwitchType switchType) { - if (null == splitOrMergeTracker || isInMaintenanceMode()) { + try { + if (null == splitOrMergeTracker || isInMaintenanceMode()) { + return false; + } + } catch (IOException e) { return false; } return splitOrMergeTracker.isSplitOrMergeEnabled(switchType); http://git-wip-us.apache.org/repos/asf/hbase/blob/a45763df/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index fa4ddf5..d3202ce 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -1491,7 +1491,11 @@ public class MasterRpcServices extends RSRpcServices final RpcController controller, final IsInMaintenanceModeRequest request) throws ServiceException { IsInMaintenanceModeResponse.Builder response = IsInMaintenanceModeResponse.newBuilder(); - response.setInMaintenanceMode(master.isInMaintenanceMode()); + try { + response.setInMaintenanceMode(master.isInMaintenanceMode()); + } catch (IOException e) { + throw new ServiceException(e); + } return response.build(); } http://git-wip-us.apache.org/repos/asf/hbase/blob/a45763df/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java index 52046c5..3d2b9af 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java @@ -352,8 +352,9 @@ public interface MasterServices extends Server { /** * @return true if master is in maintanceMode + * @throws IOException if the inquiry failed due to an IO problem */ - boolean isInMaintenanceMode(); + boolean isInMaintenanceMode() throws IOException; /** * Abort a procedure.