From c5a8650ffdd8b89994a98321ef3abc7193ba0a52 Mon Sep 17 00:00:00 2001 From: Apekshit Date: Fri, 15 Jan 2016 17:08:09 -0800 Subject: [PATCH] HBASE-15123 Remove duplicate code in following overloaded functions of LocalHBaseCluster: - waitOnMaster - waitOnRegionServer Also minor formatting changes. (Apekshit) --- .../org/apache/hadoop/hbase/LocalHBaseCluster.java | 66 +++++----------------- .../org/apache/hadoop/hbase/MiniHBaseCluster.java | 5 +- 2 files changed, 15 insertions(+), 56 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 9c292cc..82dc934 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 @@ -273,53 +273,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()) { @@ -369,46 +347,28 @@ 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); - while (masterThread.isAlive()) { - try { - LOG.info("Waiting on " + masterThread.getMaster().getServerName().toString()); - masterThread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - return masterThread.getName(); + 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. - * @param 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()); + LOG.info("Waiting on " + masterThread.getMaster().getServerName().toString()); masterThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } } - for (int i=0;i() { public Object run() { -- 2.3.2 (Apple Git-55)