hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [1/5] hbase git commit: HBASE-15123 Remove duplicate code in LocalHBaseCluster and minor formatting (Appy)
Date Wed, 27 Jan 2016 01:39:05 GMT
Repository: hbase
Updated Branches:
  refs/heads/hbase-12439 a87d9560f -> d4610df32


HBASE-15123 Remove duplicate code in LocalHBaseCluster and minor formatting (Appy)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/d6b3d838
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/d6b3d838
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/d6b3d838

Branch: refs/heads/hbase-12439
Commit: d6b3d838eba382f6b7734ca1f40fa58eb97a4f89
Parents: a87d956
Author: stack <stack@apache.org>
Authored: Mon Jan 25 13:00:08 2016 -0400
Committer: stack <stack@apache.org>
Committed: Mon Jan 25 13:00:08 2016 -0400

----------------------------------------------------------------------
 .../apache/hadoop/hbase/LocalHBaseCluster.java  | 66 ++++----------------
 .../apache/hadoop/hbase/MiniHBaseCluster.java   |  5 +-
 2 files changed, 15 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/d6b3d838/hbase-server/src/main/java/org/apache/hadoop/hbase/LocalHBaseCluster.java
----------------------------------------------------------------------
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<regionThreads.size();i++) {
-      if (regionThreads.get(i) == rst) {
-        regionThreads.remove(i);
-        break;
-      }
-    }
+    regionThreads.remove(rst);
     return rst.getName();
   }
 
   /**
-   * @param serverNumber
    * @return the HMaster thread
    */
   public HMaster getMaster(int serverNumber) {
@@ -357,8 +336,7 @@ public class LocalHBaseCluster {
    * this list).
    */
   public List<JVMClusterUtil.MasterThread> getLiveMasters() {
-    List<JVMClusterUtil.MasterThread> liveServers =
-      new ArrayList<JVMClusterUtil.MasterThread>();
+    List<JVMClusterUtil.MasterThread> liveServers = new ArrayList<>();
     List<JVMClusterUtil.MasterThread> 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<masterThreads.size();i++) {
-      if (masterThreads.get(i) == masterThread) {
-        masterThreads.remove(i);
-        break;
-      }
-    }
+    masterThreads.remove(masterThread);
     return masterThread.getName();
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/d6b3d838/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
index c2d273b..3bd3c3f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
@@ -75,8 +75,7 @@ public class MiniHBaseCluster extends HBaseCluster {
    * @param numRegionServers initial number of region servers to start.
    * @throws IOException
    */
-  public MiniHBaseCluster(Configuration conf, int numMasters,
-                             int numRegionServers)
+  public MiniHBaseCluster(Configuration conf, int numMasters, int numRegionServers)
       throws IOException, InterruptedException {
     this(conf, numMasters, numRegionServers, null, null);
   }
@@ -108,7 +107,6 @@ public class MiniHBaseCluster extends HBaseCluster {
   public static class MiniHBaseClusterRegionServer extends HRegionServer {
     private Thread shutdownThread = null;
     private User user = null;
-    public static boolean TEST_SKIP_CLOSE = false;
 
     public MiniHBaseClusterRegionServer(Configuration conf, CoordinatedStateManager cp)
         throws IOException, InterruptedException {
@@ -161,6 +159,7 @@ public class MiniHBaseCluster extends HBaseCluster {
       super.kill();
     }
 
+    @Override
     public void abort(final String reason, final Throwable cause) {
       this.user.runAs(new PrivilegedAction<Object>() {
         public Object run() {


Mime
View raw message