accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject svn commit: r1336398 - /accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/util/Initialize.java
Date Wed, 09 May 2012 21:07:04 GMT
Author: vines
Date: Wed May  9 21:07:04 2012
New Revision: 1336398

URL: http://svn.apache.org/viewvc?rev=1336398&view=rev
Log:
Accumulo-459 - Zookeeper is made to recheck on failure, so detecting failure is a bit more
difficult. However, that doesn't mean we can't be informative for the user if it's not availabile.

Modified:
    accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/util/Initialize.java

Modified: accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/util/Initialize.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/util/Initialize.java?rev=1336398&r1=1336397&r2=1336398&view=diff
==============================================================================
--- accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/util/Initialize.java
(original)
+++ accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/util/Initialize.java
Wed May  9 21:07:04 2012
@@ -115,6 +115,11 @@ public class Initialize {
     
     log.info("Accumulo data dir is " + ServerConstants.getBaseDir());
     log.info("Zookeeper server is " + ServerConfiguration.getSiteConfiguration().get(Property.INSTANCE_ZK_HOST));
+    log.info("Checking if Zookeeper is available. If this hangs, then you need to make sure
zookeeper is running");
+    if (!zookeeperAvailable()) {
+      log.fatal("Zookeeper needs to be up and running in order to init. Exiting ...");
+      return false;
+    }
     if (ServerConfiguration.getSiteConfiguration().get(Property.INSTANCE_SECRET).equals(Property.INSTANCE_SECRET.getDefaultValue()))
{
       ConsoleReader c = getConsoleReader();
       c.beep();
@@ -177,6 +182,20 @@ public class Initialize {
     return true;
   }
   
+  /**
+   * @return
+   */
+  private static boolean zookeeperAvailable() {
+    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
+    try {
+      return zoo.exists("/");
+    } catch (KeeperException e) {
+      return false;
+    } catch (InterruptedException e) {
+      return false;
+    }
+  }
+
   private static void initFileSystem(FileSystem fs, Configuration conf, UUID uuid) throws
IOException {
     FileStatus fstat;
     



Mime
View raw message