accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1398399 - /accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooSession.java
Date Mon, 15 Oct 2012 17:21:11 GMT
Author: ecn
Date: Mon Oct 15 17:21:10 2012
New Revision: 1398399

URL: http://svn.apache.org/viewvc?rev=1398399&view=rev
Log:
ACCUMULO-131 throw an exception if you can not reach zookeeper in 2x timeout period

Modified:
    accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooSession.java

Modified: accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooSession.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooSession.java?rev=1398399&r1=1398398&r2=1398399&view=diff
==============================================================================
--- accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooSession.java
(original)
+++ accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/zookeeper/ZooSession.java
Mon Oct 15 17:21:10 2012
@@ -77,6 +77,8 @@ class ZooSession {
     int sleepTime = 100;
     ZooKeeper zooKeeper = null;
     
+    long startTime = System.currentTimeMillis();
+
     while (tryAgain) {
       try {
         zooKeeper = new ZooKeeper(host, timeout, watcher);
@@ -89,6 +91,10 @@ class ZooSession {
           } else
             UtilWaitThread.sleep(TIME_BETWEEN_CONNECT_CHECKS_MS);
         }
+        
+        if (System.currentTimeMillis() - startTime > 2 * timeout)
+          throw new RuntimeException("Failed to connect to zookeeper (" + host + ") within
2x zookeeper timeout period " + timeout);
+
       } catch (UnknownHostException uhe) {
         // do not expect to recover from this
         log.warn(uhe.getClass().getName() + " : " + uhe.getMessage());



Mime
View raw message