hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1405440 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/master/ test/java/org/apache/hadoop/hbase/ test/java/org/apache/hadoop/hbase/master/ test/java/org/apache/hadoop/hbase/regionserver/
Date Sat, 03 Nov 2012 22:55:06 GMT
Author: larsh
Date: Sat Nov  3 22:55:05 2012
New Revision: 1405440

URL: http://svn.apache.org/viewvc?rev=1405440&view=rev
Log:
HBASE-6389 Modify the conditions to ensure that Master waits for sufficient number of Region
Servers before starting region assignments (Aditya Kishore)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestRSKilledWhenMasterInitializing.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=1405440&r1=1405439&r2=1405440&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java Sat
Nov  3 22:55:05 2012
@@ -66,6 +66,18 @@ import org.apache.hadoop.hbase.regionser
  * server from the original instance.
  */
 public class ServerManager {
+  public static final String WAIT_ON_REGIONSERVERS_MAXTOSTART =
+      "hbase.master.wait.on.regionservers.maxtostart";
+
+  public static final String WAIT_ON_REGIONSERVERS_MINTOSTART =
+      "hbase.master.wait.on.regionservers.mintostart";
+
+  public static final String WAIT_ON_REGIONSERVERS_TIMEOUT =
+      "hbase.master.wait.on.regionservers.timeout";
+
+  public static final String WAIT_ON_REGIONSERVERS_INTERVAL =
+      "hbase.master.wait.on.regionservers.interval";
+
   private static final Log LOG = LogFactory.getLog(ServerManager.class);
 
   // Set if we are to shutdown the cluster.
@@ -557,25 +569,38 @@ public class ServerManager {
    * Wait for the region servers to report in.
    * We will wait until one of this condition is met:
    *  - the master is stopped
-   *  - the 'hbase.master.wait.on.regionservers.timeout' is reached
    *  - the 'hbase.master.wait.on.regionservers.maxtostart' number of
    *    region servers is reached
    *  - the 'hbase.master.wait.on.regionservers.mintostart' is reached AND
    *   there have been no new region server in for
-   *      'hbase.master.wait.on.regionservers.interval' time
+   *      'hbase.master.wait.on.regionservers.interval' time AND
+   *   the 'hbase.master.wait.on.regionservers.timeout' is reached
    *
    * @throws InterruptedException
    */
   public void waitForRegionServers(MonitoredTask status)
   throws InterruptedException {
     final long interval = this.master.getConfiguration().
-      getLong("hbase.master.wait.on.regionservers.interval", 1500);
+      getLong(WAIT_ON_REGIONSERVERS_INTERVAL, 1500);
     final long timeout = this.master.getConfiguration().
-    getLong("hbase.master.wait.on.regionservers.timeout", 4500);
-    final int minToStart = this.master.getConfiguration().
-    getInt("hbase.master.wait.on.regionservers.mintostart", 1);
-    final int maxToStart = this.master.getConfiguration().
-    getInt("hbase.master.wait.on.regionservers.maxtostart", Integer.MAX_VALUE);
+      getLong(WAIT_ON_REGIONSERVERS_TIMEOUT, 4500);
+    int minToStart = this.master.getConfiguration().
+      getInt(WAIT_ON_REGIONSERVERS_MINTOSTART, 1);
+    if (minToStart < 1) {
+      LOG.warn(String.format(
+        "The value of '%s' (%d) can not be less than 1, ignoring.",
+        WAIT_ON_REGIONSERVERS_MINTOSTART, minToStart));
+      minToStart = 1;
+    }
+    int maxToStart = this.master.getConfiguration().
+      getInt(WAIT_ON_REGIONSERVERS_MAXTOSTART, Integer.MAX_VALUE);
+    if (maxToStart < minToStart) {
+        LOG.warn(String.format(
+            "The value of '%s' (%d) is set less than '%s' (%d), ignoring.",
+            WAIT_ON_REGIONSERVERS_MAXTOSTART, maxToStart,
+            WAIT_ON_REGIONSERVERS_MINTOSTART, minToStart));
+        maxToStart = Integer.MAX_VALUE;
+    }
 
     long now =  System.currentTimeMillis();
     final long startTime = now;
@@ -586,9 +611,8 @@ public class ServerManager {
     int oldCount = 0;
     while (
       !this.master.isStopped() &&
-        slept < timeout &&
         count < maxToStart &&
-        (lastCountChange+interval > now || count < minToStart)
+        (lastCountChange+interval > now || timeout > slept || count < minToStart)
       ){
 
       // Log some info at every interval time or if there is a change

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=1405440&r1=1405439&r2=1405440&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java Sat
Nov  3 22:55:05 2012
@@ -63,6 +63,7 @@ import org.apache.hadoop.hbase.io.hfile.
 import org.apache.hadoop.hbase.io.hfile.Compression;
 import org.apache.hadoop.hbase.io.hfile.Compression.Algorithm;
 import org.apache.hadoop.hbase.master.HMaster;
+import org.apache.hadoop.hbase.master.ServerManager;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.regionserver.InternalScanner;
@@ -73,6 +74,7 @@ import org.apache.hadoop.hbase.security.
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.hbase.util.JVMClusterUtil;
+import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread;
 import org.apache.hadoop.hbase.util.RegionSplitter;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.hbase.util.Writables;
@@ -627,9 +629,13 @@ public class HBaseTestingUtility {
     createRootDir();
 
     // These settings will make the server waits until this exact number of
-    //  regions servers are connected.
-    conf.setInt("hbase.master.wait.on.regionservers.mintostart", numSlaves);
-    conf.setInt("hbase.master.wait.on.regionservers.maxtostart", numSlaves);
+    // regions servers are connected.
+    if (conf.getInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, -1) == -1) {
+      conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, numSlaves);
+    }
+    if (conf.getInt(ServerManager.WAIT_ON_REGIONSERVERS_MAXTOSTART, -1) == -1) {
+      conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MAXTOSTART, numSlaves);
+    }
 
     Configuration c = new Configuration(this.conf);
     this.hbaseCluster = new MiniHBaseCluster(c, numMasters, numSlaves);
@@ -709,6 +715,9 @@ public class HBaseTestingUtility {
       hbaseAdmin.close();
       hbaseAdmin = null;
     }
+    // unset the configuration for MIN and MAX RS to start
+    conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, -1);
+    conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MAXTOSTART, -1);
     if (this.hbaseCluster != null) {
       this.hbaseCluster.shutdown();
       // Wait till hbase is down before going on to shutdown zk.
@@ -1360,6 +1369,27 @@ public class HBaseTestingUtility {
   public void expireRegionServerSession(int index) throws Exception {
     HRegionServer rs = hbaseCluster.getRegionServer(index);
     expireSession(rs.getZooKeeper(), false);
+    decrementMinRegionServerCount();
+  }
+
+  private void decrementMinRegionServerCount() {
+    // decrement the count for this.conf, for newly spwaned master
+    // this.hbaseCluster shares this configuration too
+    decrementMinRegionServerCount(getConfiguration());
+
+    // each master thread keeps a copy of configuration
+    for (MasterThread master : getHBaseCluster().getMasterThreads()) {
+      decrementMinRegionServerCount(master.getMaster().getConfiguration());
+    }
+  }
+
+  private void decrementMinRegionServerCount(Configuration conf) {
+    int currentCount = conf.getInt(
+        ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, -1);
+    if (currentCount != -1) {
+      conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART,
+          Math.max(currentCount - 1, 1));
+    }
   }
 
    /**

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java?rev=1405440&r1=1405439&r2=1405440&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
Sat Nov  3 22:55:05 2012
@@ -308,8 +308,8 @@ public class TestMasterFailover {
     // Need to drop the timeout much lower
     conf.setInt("hbase.master.assignment.timeoutmonitor.period", 2000);
     conf.setInt("hbase.master.assignment.timeoutmonitor.timeout", 4000);
-    conf.setInt("hbase.master.wait.on.regionservers.mintostart", 3);
-    conf.setInt("hbase.master.wait.on.regionservers.maxtostart", 3);
+    conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 3);
+    conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MAXTOSTART, 3);
 
     // Start the cluster
     HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);
@@ -608,8 +608,8 @@ public class TestMasterFailover {
     // Need to drop the timeout much lower
     conf.setInt("hbase.master.assignment.timeoutmonitor.period", 2000);
     conf.setInt("hbase.master.assignment.timeoutmonitor.timeout", 4000);
-    conf.setInt("hbase.master.wait.on.regionservers.mintostart", 1);
-    conf.setInt("hbase.master.wait.on.regionservers.maxtostart", 2);
+    conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 1);
+    conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MAXTOSTART, 2);
 
     // Create and start the cluster
     HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(conf);

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestRSKilledWhenMasterInitializing.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestRSKilledWhenMasterInitializing.java?rev=1405440&r1=1405439&r2=1405440&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestRSKilledWhenMasterInitializing.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestRSKilledWhenMasterInitializing.java
Sat Nov  3 22:55:05 2012
@@ -66,8 +66,11 @@ public class TestRSKilledWhenMasterIniti
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
     // Set it so that this test runs with my custom master
-    TESTUTIL.getConfiguration().setClass(HConstants.MASTER_IMPL,
-        TestingMaster.class, HMaster.class);
+    Configuration conf = TESTUTIL.getConfiguration();
+    conf.setClass(HConstants.MASTER_IMPL, TestingMaster.class, HMaster.class);
+    conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 3);
+    conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MAXTOSTART, 4);
+
     // Start up the cluster.
     TESTUTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
   }



Mime
View raw message