You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by en...@apache.org on 2012/11/08 23:25:14 UTC

svn commit: r1407300 - /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java

Author: enis
Date: Thu Nov  8 22:25:14 2012
New Revision: 1407300

URL: http://svn.apache.org/viewvc?rev=1407300&view=rev
Log:
HBASE-6831. [WINDOWS] HBaseTestingUtility.expireSession() does not expire zookeeper session

Modified:
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=1407300&r1=1407299&r2=1407300&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java Thu Nov  8 22:25:14 2012
@@ -98,6 +98,7 @@ import org.apache.zookeeper.KeeperExcept
 import org.apache.zookeeper.KeeperException.NodeExistsException;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.ZooKeeper.States;
 
 /**
  * Facility for testing HBase. Replacement for
@@ -1621,6 +1622,14 @@ public class HBaseTestingUtility {
     // Making it expire
     ZooKeeper newZK = new ZooKeeper(quorumServers,
         1000, EmptyWatcher.instance, sessionID, password);
+
+    //ensure that we have connection to the server before closing down, otherwise
+    //the close session event will be eaten out before we start CONNECTING state
+    long start = System.currentTimeMillis();
+    while (newZK.getState() != States.CONNECTED 
+         && System.currentTimeMillis() - start < 1000) {
+       Thread.sleep(1);
+    }
     newZK.close();
     LOG.info("ZK Closed Session 0x" + Long.toHexString(sessionID));