This is an automated email from the ASF dual-hosted git repository.

stack pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new b71ef1e  HBASE-24052 Add debug to TestMasterShutdown
b71ef1e is described below

commit b71ef1e94ac01f792f87e2e831a5d8b4fb7eeca7
Author: stack <st...@apache.org>
AuthorDate: Wed Mar 25 22:42:19 2020 -0700

    HBASE-24052 Add debug to TestMasterShutdown
---
 .../org/apache/hadoop/hbase/master/HMaster.java     |  1 +
 .../master/procedure/RSProcedureDispatcher.java     | 21 ++++++++++++++++++---
 .../hadoop/hbase/master/TestMasterShutdown.java     |  3 ++-
 3 files changed, 21 insertions(+), 4 deletions(-)

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 970cda8..232b3ab 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
@@ -2751,6 +2751,7 @@ public class HMaster extends HRegionServer implements 
MasterServices {
   @Override
   public void abort(String reason, Throwable cause) {
     if (isAborted() || isStopped()) {
+      LOG.debug("Abort called but aborted={}, stopped={}", isAborted(), 
isStopped());
       return;
     }
     setAbortRequested();
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RSProcedureDispatcher.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RSProcedureDispatcher.java
index 10b823c..ea5a165 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RSProcedureDispatcher.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/RSProcedureDispatcher.java
@@ -30,6 +30,7 @@ import 
org.apache.hadoop.hbase.ipc.ServerNotRunningYetException;
 import org.apache.hadoop.hbase.master.MasterServices;
 import org.apache.hadoop.hbase.master.ServerListener;
 import org.apache.hadoop.hbase.master.ServerManager;
+import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
 import org.apache.hadoop.hbase.procedure2.RemoteProcedureDispatcher;
 import org.apache.hadoop.hbase.regionserver.RegionServerAbortedException;
 import org.apache.hadoop.hbase.regionserver.RegionServerStoppedException;
@@ -95,10 +96,24 @@ public class RSProcedureDispatcher
       return false;
     }
     // Around startup, if failed, some of the below may be set back to null so 
NPE is possible.
+    ServerManager sm = master.getServerManager();
+    if (sm == null) {
+      LOG.debug("ServerManager is null; stopping={}", master.isStopping());
+      return false;
+    }
+    sm.registerListener(this);
+    ProcedureExecutor<MasterProcedureEnv> pe = 
master.getMasterProcedureExecutor();
+    if (pe == null) {
+      LOG.debug("ProcedureExecutor is null; stopping={}", master.isStopping());
+      return false;
+    }
+    procedureEnv = pe.getEnvironment();
+    if (this.procedureEnv == null) {
+      LOG.debug("ProcedureEnv is null; stopping={}", master.isStopping());
+      return false;
+    }
     try {
-      master.getServerManager().registerListener(this);
-      procedureEnv = master.getMasterProcedureExecutor().getEnvironment();
-      for (ServerName serverName : 
master.getServerManager().getOnlineServersList()) {
+      for (ServerName serverName : sm.getOnlineServersList()) {
         addNode(serverName);
       }
     } catch (Exception e) {
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterShutdown.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterShutdown.java
index a5e596f..4dc6262 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterShutdown.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterShutdown.java
@@ -168,7 +168,8 @@ public class TestMasterShutdown {
         final long timeout = TimeUnit.MINUTES.toMillis(10);
         assertNotEquals("timeout waiting for server manager to become 
available.",
           -1, Waiter.waitFor(htu.getConfiguration(), timeout,
-            () -> masterThread.getMaster().getServerManager() != null));
+            () -> masterThread.getMaster().getServerManager() != null &&
+              !masterThread.getMaster().isStopping()));
 
         // Master has come up far enough that we can terminate it without 
creating a zombie.
         final long result = Waiter.waitFor(htu.getConfiguration(), timeout, 
500, () -> {

Reply via email to