Ejemplo n.º 1
0
 /**
  * Start watching a node, optionnaly waiting for it to be created
  *
  * @param zk
  * @param nodePath
  * @param waitForCreation
  * @throws KeeperException
  * @throws InterruptedException
  */
 protected WatchedNode(final ZooKeeperPlus zk, final String nodePath, boolean waitForCreation)
     throws KeeperException, InterruptedException {
   this.zk = zk;
   this.nodePath = nodePath;
   // Immediately try to load the data, if it fails, then optionally wait
   try {
     watchForData();
   } catch (KeeperException.NoNodeException e) {
     if (waitForCreation) {
       NodeCreationBarrier.block(zk, nodePath);
       watchForData();
     } else {
       watchForCreation();
     }
   }
 }