Beispiel #1
0
 /** Returns true if path exists */
 public Boolean exists(final String path, boolean retryOnConnLoss)
     throws KeeperException, InterruptedException {
   if (retryOnConnLoss) {
     return zkCmdExecutor.retryOperation(
         new ZkOperation() {
           @Override
           public Boolean execute() throws KeeperException, InterruptedException {
             return keeper.exists(path, null) != null;
           }
         });
   } else {
     return keeper.exists(path, null) != null;
   }
 }
Beispiel #2
0
 /**
  * Return the stat of the node of the given path. Return null if no such a node exists.
  *
  * <p>If the watch is non-null and the call is successful (no exception is thrown), a watch will
  * be left on the node with the given path. The watch will be triggered by a successful operation
  * that creates/delete the node or sets the data on the node.
  *
  * @param path the node path
  * @param watcher explicit watcher
  * @return the stat of the node of the given path; return null if no such a node exists.
  * @throws KeeperException If the server signals an error
  * @throws InterruptedException If the server transaction is interrupted.
  * @throws IllegalArgumentException if an invalid path is specified
  */
 public Stat exists(final String path, final Watcher watcher, boolean retryOnConnLoss)
     throws KeeperException, InterruptedException {
   if (retryOnConnLoss) {
     return zkCmdExecutor.retryOperation(
         new ZkOperation() {
           @Override
           public Stat execute() throws KeeperException, InterruptedException {
             return keeper.exists(path, watcher);
           }
         });
   } else {
     return keeper.exists(path, watcher);
   }
 }