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;
 }
 public synchronized void initConfigInZKDatabase(QuorumVerifier qv) {
   if (qv == null) return; // only happens during tests
   try {
     if (this.dataTree.getNode(ZooDefs.CONFIG_NODE) == null) {
       // should only happen during upgrade
       LOG.warn(
           "configuration znode missing (hould only happen during upgrade), creating the node");
       this.dataTree.addConfigNode();
     }
     this.dataTree.setData(
         ZooDefs.CONFIG_NODE,
         qv.toString().getBytes(),
         -1,
         qv.getVersion(),
         Time.currentWallTime());
   } catch (NoNodeException e) {
     System.out.println("configuration node missing - should not happen");
   }
 }
 void updateNow() {
   now = Time.currentElapsedTime();
 }