HBASE-6831. [WINDOWS] HBaseTestingUtility.expireSession() does not expire zookeeper session

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1407300 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Enis Soztutar 2012-11-08 22:25:14 +00:00
parent 8d079e7ca5
commit 5497b3c155
1 changed files with 9 additions and 0 deletions

View File

@ -98,6 +98,7 @@ import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NodeExistsException; import org.apache.zookeeper.KeeperException.NodeExistsException;
import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.ZooKeeper.States;
/** /**
* Facility for testing HBase. Replacement for * Facility for testing HBase. Replacement for
@ -1621,6 +1622,14 @@ public class HBaseTestingUtility {
// Making it expire // Making it expire
ZooKeeper newZK = new ZooKeeper(quorumServers, ZooKeeper newZK = new ZooKeeper(quorumServers,
1000, EmptyWatcher.instance, sessionID, password); 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(); newZK.close();
LOG.info("ZK Closed Session 0x" + Long.toHexString(sessionID)); LOG.info("ZK Closed Session 0x" + Long.toHexString(sessionID));