accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [43/50] [abbrv] git commit: ACCUMULO-2676 Make minicluster ZooKeeper startup wait time configurable
Date Sat, 14 Jun 2014 04:36:24 GMT
ACCUMULO-2676 Make minicluster ZooKeeper startup wait time configurable

Signed-off-by: Bill Havanki <bhavanki@cloudera.com>


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

Branch: refs/heads/ACCUMULO-378
Commit: 8b2f2dce8e580ae876531034afabd61150b8fb3a
Parents: 8717750
Author: David S. Wang <dsw@cloudera.com>
Authored: Fri Jun 13 06:02:59 2014 -0700
Committer: Bill Havanki <bhavanki@cloudera.com>
Committed: Fri Jun 13 09:23:27 2014 -0400

----------------------------------------------------------------------
 .../apache/accumulo/cluster/AccumuloConfig.java | 11 +++++++++++
 .../minicluster/MiniAccumuloConfig.java         | 14 ++++++++++++++
 .../minicluster/MiniAccumuloRunner.java         |  4 ++++
 .../impl/MiniAccumuloClusterImpl.java           |  6 ++----
 .../impl/MiniAccumuloConfigImpl.java            | 20 ++++++++++++++++++++
 .../impl/MiniAccumuloConfigImplTest.java        |  8 ++++++++
 6 files changed, 59 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/8b2f2dce/minicluster/src/main/java/org/apache/accumulo/cluster/AccumuloConfig.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/cluster/AccumuloConfig.java b/minicluster/src/main/java/org/apache/accumulo/cluster/AccumuloConfig.java
index eb373c7..0df2348 100644
--- a/minicluster/src/main/java/org/apache/accumulo/cluster/AccumuloConfig.java
+++ b/minicluster/src/main/java/org/apache/accumulo/cluster/AccumuloConfig.java
@@ -61,6 +61,17 @@ public interface AccumuloConfig {
   public AccumuloConfig setZooKeeperPort(int zooKeeperPort);
 
   /**
+   * Configure the time to wait for ZooKeeper to startup.
+   * Calling this method is optional. The default is 20000 milliseconds
+   *
+   * @param zooKeeperStartupTime
+   *          Time to wait for ZooKeeper to startup, in milliseconds
+   *
+   * @since 1.6.1
+   */
+  public AccumuloConfig setZooKeeperStartupTime(long zooKeeperStartupTime);
+
+  /**
    * Sets the amount of memory to use in the master process. Calling this method is optional.
Default memory is 128M
    *
    * @param serverType

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8b2f2dce/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java
b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java
index 092af2a..980097e 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloConfig.java
@@ -95,6 +95,20 @@ public class MiniAccumuloConfig {
   }
 
   /**
+   * Configure the time to wait for ZooKeeper to startup.
+   * Calling this method is optional. The default is 20000 milliseconds
+   * 
+   * @param zooKeeperStartupTime
+   *          Time to wait for ZooKeeper to startup, in milliseconds
+   * 
+   * @since 1.6.1
+   */
+  public MiniAccumuloConfig setZooKeeperStartupTime(long zooKeeperStartupTime) {
+    impl.setZooKeeperStartupTime(zooKeeperStartupTime);
+    return this;
+  }
+
+  /**
    * Sets the amount of memory to use in the master process. Calling this method is optional.
Default memory is 128M
    * 
    * @param serverType

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8b2f2dce/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
index ab84d37..cd4a465 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
@@ -67,6 +67,7 @@ public class MiniAccumuloRunner {
   private static final String ZOO_KEEPER_MEMORY_PROP = "zooKeeperMemory";
   private static final String JDWP_ENABLED_PROP = "jdwpEnabled";
   private static final String ZOO_KEEPER_PORT_PROP = "zooKeeperPort";
+  private static final String ZOO_KEEPER_STARTUP_TIME_PROP = "zooKeeperStartupTime";
   private static final String NUM_T_SERVERS_PROP = "numTServers";
   private static final String DIRECTORY_PROP = "directory";
   private static final String INSTANCE_NAME_PROP = "instanceName";
@@ -81,6 +82,7 @@ public class MiniAccumuloRunner {
     System.out.println("#" + ROOT_PASSWORD_PROP + "=secret");
     System.out.println("#" + NUM_T_SERVERS_PROP + "=2");
     System.out.println("#" + ZOO_KEEPER_PORT_PROP + "=40404");
+    System.out.println("#" + ZOO_KEEPER_STARTUP_TIME_PROP + "=39000");
     System.out.println("#" + SHUTDOWN_PORT_PROP + "=41414");
     System.out.println("#" + DEFAULT_MEMORY_PROP + "=128M");
     System.out.println("#" + MASTER_MEMORY_PROP + "=128M");
@@ -159,6 +161,8 @@ public class MiniAccumuloRunner {
       config.setNumTservers(Integer.parseInt(opts.prop.getProperty(NUM_T_SERVERS_PROP)));
     if (opts.prop.containsKey(ZOO_KEEPER_PORT_PROP))
       config.setZooKeeperPort(Integer.parseInt(opts.prop.getProperty(ZOO_KEEPER_PORT_PROP)));
+    if (opts.prop.containsKey(ZOO_KEEPER_STARTUP_TIME_PROP))
+      config.setZooKeeperStartupTime(Long.parseLong(opts.prop.getProperty(ZOO_KEEPER_STARTUP_TIME_PROP)));
     if (opts.prop.containsKey(JDWP_ENABLED_PROP))
       config.setJDWPEnabled(Boolean.parseBoolean(opts.prop.getProperty(JDWP_ENABLED_PROP)));
     if (opts.prop.containsKey(ZOO_KEEPER_MEMORY_PROP))

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8b2f2dce/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
index c82fab3..977968e 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
@@ -141,8 +141,6 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
     }
   }
 
-  private static final long ZOOKEEPER_STARTUP_WAIT = 20*1000;
-
   private boolean initialized = false;
   private Process zooKeeperProcess = null;
   private Process masterProcess = null;
@@ -473,8 +471,8 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster {
           if (n >= 4 && new String(buffer, 0, 4).equals("imok"))
             break;
         } catch (Exception e) {
-          if (System.currentTimeMillis() - startTime >= ZOOKEEPER_STARTUP_WAIT) {
-            throw new RuntimeException("Zookeeper did not start within " + (ZOOKEEPER_STARTUP_WAIT/1000)
+ " seconds. Check the logs in " + config.getLogDir() + " for errors.  Last exception: " +
e);
+          if (System.currentTimeMillis() - startTime >= config.getZooKeeperStartupTime())
{
+            throw new RuntimeException("Zookeeper did not start within " + (config.getZooKeeperStartupTime()/1000)
+ " seconds. Check the logs in " + config.getLogDir() + " for errors.  Last exception: " +
e);
           }
           UtilWaitThread.sleep(250);
         } finally {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8b2f2dce/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java
----------------------------------------------------------------------
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java
b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java
index 3258991..49773f9 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImpl.java
@@ -57,6 +57,7 @@ public class MiniAccumuloConfigImpl implements AccumuloConfig {
 
   private int zooKeeperPort = 0;
   private int configuredZookeeperPort = 0;
+  private long zooKeeperStartupTime = 20*1000;
 
   private long defaultMemorySize = 128 * 1024 * 1024;
 
@@ -212,6 +213,21 @@ public class MiniAccumuloConfigImpl implements AccumuloConfig {
   }
 
   /**
+   * Configure the time to wait for ZooKeeper to startup.
+   * Calling this method is optional. The default is 20000 milliseconds
+   * 
+   * @param zooKeeperStartupTime
+   *          Time to wait for ZooKeeper to startup, in milliseconds
+   * 
+   * @since 1.6.1
+   */
+  @Override
+  public MiniAccumuloConfigImpl setZooKeeperStartupTime(long zooKeeperStartupTime) {
+    this.zooKeeperStartupTime = zooKeeperStartupTime;
+    return this;
+  }
+
+  /**
    * Sets the amount of memory to use in the master process. Calling this method is optional.
Default memory is 128M
    * 
    * @param serverType
@@ -283,6 +299,10 @@ public class MiniAccumuloConfigImpl implements AccumuloConfig {
     return configuredZookeeperPort;
   }
 
+  public long getZooKeeperStartupTime() {
+    return zooKeeperStartupTime;
+  }
+
   File getLibDir() {
     return libDir;
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8b2f2dce/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImplTest.java
----------------------------------------------------------------------
diff --git a/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImplTest.java
b/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImplTest.java
index ff25420..dc616df 100644
--- a/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImplTest.java
+++ b/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloConfigImplTest.java
@@ -53,6 +53,14 @@ public class MiniAccumuloConfigImplTest {
     assertTrue(config.getZooKeeperPort() > 0);
   }
 
+  @Test
+  public void testZooKeeperStartupTime() {
+
+    // set specific zookeeper startup time
+    MiniAccumuloConfigImpl config = new MiniAccumuloConfigImpl(tempFolder.getRoot(), "password").setZooKeeperStartupTime(5000).initialize();
+    assertEquals(5000, config.getZooKeeperStartupTime());
+  }
+
   @SuppressWarnings("deprecation")
   @Test
   public void testSiteConfig() {


Mime
View raw message