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 fbe590f71c1..7da8e6859c9 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 @@ -272,53 +272,32 @@ public class LocalHBaseCluster { } /** - * Wait for the specified region server to stop - * Removes this thread from list of running threads. - * @param serverNumber + * 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) { - JVMClusterUtil.RegionServerThread regionServerThread = - this.regionThreads.remove(serverNumber); - while (regionServerThread.isAlive()) { - try { - LOG.info("Waiting on " + - regionServerThread.getRegionServer().toString()); - regionServerThread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - return regionServerThread.getName(); + JVMClusterUtil.RegionServerThread regionServerThread = this.regionThreads.get(serverNumber); + return waitOnRegionServer(regionServerThread); } /** - * Wait for the specified region server to stop - * Removes this thread from list of running threads. - * @param rst + * 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) { while (rst.isAlive()) { try { - LOG.info("Waiting on " + - rst.getRegionServer().toString()); + LOG.info("Waiting on " + rst.getRegionServer().toString()); rst.join(); } catch (InterruptedException e) { e.printStackTrace(); } } - for (int i=0;i getLiveMasters() { - List liveServers = - new ArrayList(); + List liveServers = new ArrayList<>(); List list = getMasters(); for (JVMClusterUtil.MasterThread mt: list) { if (mt.isAlive()) { @@ -368,13 +346,19 @@ public class LocalHBaseCluster { } /** - * Wait for the specified master to stop - * Removes this thread from list of running threads. - * @param serverNumber + * 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) { - JVMClusterUtil.MasterThread masterThread = this.masterThreads.remove(serverNumber); + JVMClusterUtil.MasterThread masterThread = this.masterThreads.get(serverNumber); + return waitOnMaster(masterThread); + } + + /** + * 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) { while (masterThread.isAlive()) { try { LOG.info("Waiting on " + masterThread.getMaster().getServerName().toString()); @@ -383,31 +367,7 @@ public class LocalHBaseCluster { e.printStackTrace(); } } - return masterThread.getName(); - } - - /** - * Wait for the specified master to stop - * Removes this thread from list of running threads. - * @param masterThread - * @return Name of master that just went down. - */ - public String waitOnMaster(JVMClusterUtil.MasterThread masterThread) { - while (masterThread.isAlive()) { - try { - LOG.info("Waiting on " + - masterThread.getMaster().getServerName().toString()); - masterThread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - for (int i=0;i() { public Object run() {