From b7ffb5692725c5e853b9ee80c280cd9a07636ac6 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Wed, 13 Apr 2022 11:54:50 +0800 Subject: [PATCH] Revert "HBASE-26941 LocalHBaseCluster.waitOnRegionServer should quit while thread is interrupted (#4333)" This reverts commit 8247b7c722f95f94afd5cb9d9b80c9ce5f61a7de. --- .../hadoop/hbase/LocalHBaseCluster.java | 28 +++++++++++++------ .../hbase/SingleProcessHBaseCluster.java | 17 +++-------- .../master/TestMasterMetricsWrapper.java | 2 +- .../apache/hadoop/hbase/MiniHBaseCluster.java | 17 +++-------- 4 files changed, 28 insertions(+), 36 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 90856672e33..329b1d050f6 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) throws InterruptedException { + public String waitOnRegionServer(int serverNumber) { JVMClusterUtil.RegionServerThread regionServerThread = this.regionThreads.get(serverNumber); return waitOnRegionServer(regionServerThread); } @@ -309,11 +309,15 @@ 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) - throws InterruptedException { + public String waitOnRegionServer(JVMClusterUtil.RegionServerThread rst) { while (rst.isAlive()) { - LOG.info("Waiting on " + rst.getRegionServer().toString()); - rst.join(); + 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(); + } } regionThreads.remove(rst); return rst.getName(); @@ -369,7 +373,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) throws InterruptedException { + public String waitOnMaster(int serverNumber) { JVMClusterUtil.MasterThread masterThread = this.masterThreads.get(serverNumber); return waitOnMaster(masterThread); } @@ -378,10 +382,16 @@ 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) throws InterruptedException { + public String waitOnMaster(JVMClusterUtil.MasterThread masterThread) { while (masterThread.isAlive()) { - LOG.info("Waiting on " + masterThread.getMaster().getServerName().toString()); - masterThread.join(); + 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(); + } } 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 feb7ccd573a..af30b58f463 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,7 +19,6 @@ 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; @@ -298,11 +297,7 @@ public class SingleProcessHBaseCluster extends HBaseClusterInterface { @Override public void waitForRegionServerToStop(ServerName serverName, long timeout) throws IOException { // ignore timeout for now - try { - waitOnRegionServer(getRegionServerIndex(serverName)); - } catch (InterruptedException e) { - throw (InterruptedIOException) new InterruptedIOException().initCause(e); - } + waitOnRegionServer(getRegionServerIndex(serverName)); } @Override @@ -398,11 +393,7 @@ public class SingleProcessHBaseCluster extends HBaseClusterInterface { @Override public void waitForMasterToStop(ServerName serverName, long timeout) throws IOException { // ignore timeout for now - try { - waitOnMaster(getMasterIndex(serverName)); - } catch (InterruptedException e) { - throw (InterruptedIOException) new InterruptedIOException().initCause(e); - } + waitOnMaster(getMasterIndex(serverName)); } /** @@ -518,7 +509,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) throws InterruptedException { + public String waitOnRegionServer(final int serverNumber) { return this.hbaseCluster.waitOnRegionServer(serverNumber); } @@ -610,7 +601,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) throws InterruptedException { + public String waitOnMaster(final int serverNumber) { 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 14a2f5675a4..960522c2463 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() throws InterruptedException { + public void testInfo() { 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 6e7bf28ab1c..7b6c697e4dd 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,7 +19,6 @@ 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; @@ -311,11 +310,7 @@ public class MiniHBaseCluster extends HBaseCluster { @Override public void waitForRegionServerToStop(ServerName serverName, long timeout) throws IOException { //ignore timeout for now - try { - waitOnRegionServer(getRegionServerIndex(serverName)); - } catch (InterruptedException e) { - throw (InterruptedIOException) new InterruptedIOException().initCause(e); - } + waitOnRegionServer(getRegionServerIndex(serverName)); } @Override @@ -411,11 +406,7 @@ public class MiniHBaseCluster extends HBaseCluster { @Override public void waitForMasterToStop(ServerName serverName, long timeout) throws IOException { //ignore timeout for now - try { - waitOnMaster(getMasterIndex(serverName)); - } catch (InterruptedException e) { - throw (InterruptedIOException) new InterruptedIOException().initCause(e); - } + waitOnMaster(getMasterIndex(serverName)); } /** @@ -544,7 +535,7 @@ public class MiniHBaseCluster extends HBaseCluster { * @param serverNumber * @return Name of region server that just went down. */ - public String waitOnRegionServer(final int serverNumber) throws InterruptedException { + public String waitOnRegionServer(final int serverNumber) { return this.hbaseCluster.waitOnRegionServer(serverNumber); } @@ -649,7 +640,7 @@ public class MiniHBaseCluster extends HBaseCluster { * @param serverNumber * @return Name of master that just went down. */ - public String waitOnMaster(final int serverNumber) throws InterruptedException { + public String waitOnMaster(final int serverNumber) { return this.hbaseCluster.waitOnMaster(serverNumber); }