HBASE-26941 LocalHBaseCluster.waitOnRegionServer should not call join while interrupted (#4352)

Signed-off-by: Xin Sun <ddupgs@gmail.com>
(cherry picked from commit 35aa57e445)
This commit is contained in:
Duo Zhang 2022-04-17 22:56:52 +08:00
parent 450a54bed8
commit cd51da1d5a
1 changed files with 13 additions and 2 deletions

View File

@ -310,15 +310,20 @@ public class LocalHBaseCluster {
* @return Name of region server that just went down.
*/
public String waitOnRegionServer(JVMClusterUtil.RegionServerThread rst) {
boolean interrupted = false;
while (rst.isAlive()) {
try {
LOG.info("Waiting on " + rst.getRegionServer().toString());
rst.join();
} catch (InterruptedException e) {
e.printStackTrace();
LOG.error("Interrupted while waiting for {} to finish. Retrying join", rst.getName(), e);
interrupted = true;
}
}
regionThreads.remove(rst);
if (interrupted) {
Thread.currentThread().interrupt();
}
return rst.getName();
}
@ -382,15 +387,21 @@ public class LocalHBaseCluster {
* @return Name of master that just went down.
*/
public String waitOnMaster(JVMClusterUtil.MasterThread masterThread) {
boolean interrupted = false;
while (masterThread.isAlive()) {
try {
LOG.info("Waiting on " + masterThread.getMaster().getServerName().toString());
masterThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
LOG.error("Interrupted while waiting for {} to finish. Retrying join",
masterThread.getName(), e);
interrupted = true;
}
}
masterThreads.remove(masterThread);
if (interrupted) {
Thread.currentThread().interrupt();
}
return masterThread.getName();
}