private synchronized boolean waitForConnect(ZooKeeper zk, long timeout)
     throws InterruptedException {
   connected = (zk.getState() == States.CONNECTED);
   long end = Time.currentElapsedTime() + timeout;
   while (!connected && end > Time.currentElapsedTime()) {
     wait(timeout);
     connected = (zk.getState() == States.CONNECTED);
   }
   return connected;
 }
 void updateNow() {
   now = Time.currentElapsedTime();
 }