You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2022/04/13 02:49:45 UTC

[hbase] branch master updated: HBASE-26941 LocalHBaseCluster.waitOnRegionServer should quit while thread is interrupted (#4333)

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

zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/master by this push:
     new 8247b7c722 HBASE-26941 LocalHBaseCluster.waitOnRegionServer should quit while thread is interrupted (#4333)
8247b7c722 is described below

commit 8247b7c722f95f94afd5cb9d9b80c9ce5f61a7de
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Wed Apr 13 10:49:40 2022 +0800

    HBASE-26941 LocalHBaseCluster.waitOnRegionServer should quit while thread is interrupted (#4333)
    
    Signed-off-by: Xin Sun <dd...@gmail.com>
---
 .../org/apache/hadoop/hbase/LocalHBaseCluster.java | 28 +++++++---------------
 .../hadoop/hbase/SingleProcessHBaseCluster.java    | 17 +++++++++----
 .../hbase/master/TestMasterMetricsWrapper.java     |  2 +-
 .../org/apache/hadoop/hbase/MiniHBaseCluster.java  | 17 +++++++++----
 4 files changed, 36 insertions(+), 28 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
index 329b1d050f..90856672e3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
@@ -300,7 +300,7 @@ public class LocalHBaseCluster {
    * Wait for the specified region server to stop. Removes this thread from list of running threads.
    * @return Name of region server that just went down.
    */
-  public String waitOnRegionServer(int serverNumber) {
+  public String waitOnRegionServer(int serverNumber) throws InterruptedException {
     JVMClusterUtil.RegionServerThread regionServerThread = this.regionThreads.get(serverNumber);
     return waitOnRegionServer(regionServerThread);
   }
@@ -309,15 +309,11 @@ public class LocalHBaseCluster {
    * Wait for the specified region server to stop. Removes this thread from list of running threads.
    * @return Name of region server that just went down.
    */
-  public String waitOnRegionServer(JVMClusterUtil.RegionServerThread rst) {
+  public String waitOnRegionServer(JVMClusterUtil.RegionServerThread rst)
+    throws InterruptedException {
     while (rst.isAlive()) {
-      try {
-        LOG.info("Waiting on " + rst.getRegionServer().toString());
-        rst.join();
-      } catch (InterruptedException e) {
-        LOG.error("Interrupted while waiting for {} to finish. Retrying join", rst.getName(), e);
-        Thread.currentThread().interrupt();
-      }
+      LOG.info("Waiting on " + rst.getRegionServer().toString());
+      rst.join();
     }
     regionThreads.remove(rst);
     return rst.getName();
@@ -373,7 +369,7 @@ public class LocalHBaseCluster {
    * Wait for the specified master to stop. Removes this thread from list of running threads.
    * @return Name of master that just went down.
    */
-  public String waitOnMaster(int serverNumber) {
+  public String waitOnMaster(int serverNumber) throws InterruptedException {
     JVMClusterUtil.MasterThread masterThread = this.masterThreads.get(serverNumber);
     return waitOnMaster(masterThread);
   }
@@ -382,16 +378,10 @@ public class LocalHBaseCluster {
    * Wait for the specified master to stop. Removes this thread from list of running threads.
    * @return Name of master that just went down.
    */
-  public String waitOnMaster(JVMClusterUtil.MasterThread masterThread) {
+  public String waitOnMaster(JVMClusterUtil.MasterThread masterThread) throws InterruptedException {
     while (masterThread.isAlive()) {
-      try {
-        LOG.info("Waiting on " + masterThread.getMaster().getServerName().toString());
-        masterThread.join();
-      } catch (InterruptedException e) {
-        LOG.error("Interrupted while waiting for {} to finish. Retrying join",
-            masterThread.getName(), e);
-        Thread.currentThread().interrupt();
-      }
+      LOG.info("Waiting on " + masterThread.getMaster().getServerName().toString());
+      masterThread.join();
     }
     masterThreads.remove(masterThread);
     return masterThread.getName();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java
index af30b58f46..feb7ccd573 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/SingleProcessHBaseCluster.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hbase;
 
 import java.io.IOException;
+import java.io.InterruptedIOException;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -297,7 +298,11 @@ public class SingleProcessHBaseCluster extends HBaseClusterInterface {
   @Override
   public void waitForRegionServerToStop(ServerName serverName, long timeout) throws IOException {
     // ignore timeout for now
-    waitOnRegionServer(getRegionServerIndex(serverName));
+    try {
+      waitOnRegionServer(getRegionServerIndex(serverName));
+    } catch (InterruptedException e) {
+      throw (InterruptedIOException) new InterruptedIOException().initCause(e);
+    }
   }
 
   @Override
@@ -393,7 +398,11 @@ public class SingleProcessHBaseCluster extends HBaseClusterInterface {
   @Override
   public void waitForMasterToStop(ServerName serverName, long timeout) throws IOException {
     // ignore timeout for now
-    waitOnMaster(getMasterIndex(serverName));
+    try {
+      waitOnMaster(getMasterIndex(serverName));
+    } catch (InterruptedException e) {
+      throw (InterruptedIOException) new InterruptedIOException().initCause(e);
+    }
   }
 
   /**
@@ -509,7 +518,7 @@ public class SingleProcessHBaseCluster extends HBaseClusterInterface {
    * Wait for the specified region server to stop. Removes this thread from list of running threads.
    * @return Name of region server that just went down.
    */
-  public String waitOnRegionServer(final int serverNumber) {
+  public String waitOnRegionServer(final int serverNumber) throws InterruptedException {
     return this.hbaseCluster.waitOnRegionServer(serverNumber);
   }
 
@@ -601,7 +610,7 @@ public class SingleProcessHBaseCluster extends HBaseClusterInterface {
    * Wait for the specified master to stop. Removes this thread from list of running threads.
    * @return Name of master that just went down.
    */
-  public String waitOnMaster(final int serverNumber) {
+  public String waitOnMaster(final int serverNumber) throws InterruptedException {
     return this.hbaseCluster.waitOnMaster(serverNumber);
   }
 
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java
index 960522c246..14a2f5675a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetricsWrapper.java
@@ -70,7 +70,7 @@ public class TestMasterMetricsWrapper {
   }
 
   @Test
-  public void testInfo() {
+  public void testInfo() throws InterruptedException {
     HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
     MetricsMasterWrapperImpl info = new MetricsMasterWrapperImpl(master);
     assertEquals(
diff --git a/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
index 7b6c697e4d..6e7bf28ab1 100644
--- a/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
+++ b/hbase-testing-util/src/main/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hbase;
 
 import java.io.IOException;
+import java.io.InterruptedIOException;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -310,7 +311,11 @@ public class MiniHBaseCluster extends HBaseCluster {
   @Override
   public void waitForRegionServerToStop(ServerName serverName, long timeout) throws IOException {
     //ignore timeout for now
-    waitOnRegionServer(getRegionServerIndex(serverName));
+    try {
+      waitOnRegionServer(getRegionServerIndex(serverName));
+    } catch (InterruptedException e) {
+      throw (InterruptedIOException) new InterruptedIOException().initCause(e);
+    }
   }
 
   @Override
@@ -406,7 +411,11 @@ public class MiniHBaseCluster extends HBaseCluster {
   @Override
   public void waitForMasterToStop(ServerName serverName, long timeout) throws IOException {
     //ignore timeout for now
-    waitOnMaster(getMasterIndex(serverName));
+    try {
+      waitOnMaster(getMasterIndex(serverName));
+    } catch (InterruptedException e) {
+      throw (InterruptedIOException) new InterruptedIOException().initCause(e);
+    }
   }
 
   /**
@@ -535,7 +544,7 @@ public class MiniHBaseCluster extends HBaseCluster {
    * @param serverNumber
    * @return Name of region server that just went down.
    */
-  public String waitOnRegionServer(final int serverNumber) {
+  public String waitOnRegionServer(final int serverNumber) throws InterruptedException {
     return this.hbaseCluster.waitOnRegionServer(serverNumber);
   }
 
@@ -640,7 +649,7 @@ public class MiniHBaseCluster extends HBaseCluster {
    * @param serverNumber
    * @return Name of master that just went down.
    */
-  public String waitOnMaster(final int serverNumber) {
+  public String waitOnMaster(final int serverNumber) throws InterruptedException {
     return this.hbaseCluster.waitOnMaster(serverNumber);
   }