Class ZKUtil


  • public class ZKUtil
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ZKUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void deleteRecursive​(ZooKeeper zk, java.lang.String pathRoot)
      Recursively delete the node with the given path.
      static void deleteRecursive​(ZooKeeper zk, java.lang.String pathRoot, AsyncCallback.VoidCallback cb, java.lang.Object ctx)
      Recursively delete the node with the given path.
      static java.util.List<java.lang.String> listSubTreeBFS​(ZooKeeper zk, java.lang.String pathRoot)
      BFS Traversal of the system under pathRoot, with the entries in the list, in the same order as that of the traversal.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ZKUtil

        public ZKUtil()
    • Method Detail

      • deleteRecursive

        public static void deleteRecursive​(ZooKeeper zk,
                                           java.lang.String pathRoot)
                                    throws java.lang.InterruptedException,
                                           KeeperException
        Recursively delete the node with the given path.

        Important: All versions, of all nodes, under the given node are deleted.

        If there is an error with deleting one of the sub-nodes in the tree, this operation would abort and would be the responsibility of the app to handle the same. See #delete(String, int) for more details.

        Throws:
        java.lang.IllegalArgumentException - if an invalid path is specified
        java.lang.InterruptedException
        KeeperException
      • deleteRecursive

        public static void deleteRecursive​(ZooKeeper zk,
                                           java.lang.String pathRoot,
                                           AsyncCallback.VoidCallback cb,
                                           java.lang.Object ctx)
                                    throws java.lang.InterruptedException,
                                           KeeperException
        Recursively delete the node with the given path. (async version).

        Important: All versions, of all nodes, under the given node are deleted.

        If there is an error with deleting one of the sub-nodes in the tree, this operation would abort and would be the responsibility of the app to handle the same.

        Parameters:
        zk - the zookeeper handle
        pathRoot - the path to be deleted
        cb - call back method
        ctx - the context the callback method is called with
        Throws:
        java.lang.IllegalArgumentException - if an invalid path is specified
        java.lang.InterruptedException
        KeeperException
      • listSubTreeBFS

        public static java.util.List<java.lang.String> listSubTreeBFS​(ZooKeeper zk,
                                                                      java.lang.String pathRoot)
                                                               throws KeeperException,
                                                                      java.lang.InterruptedException
        BFS Traversal of the system under pathRoot, with the entries in the list, in the same order as that of the traversal.

        Important: This is not an atomic snapshot of the tree ever, but the state as it exists across multiple RPCs from zkClient to the ensemble. For practical purposes, it is suggested to bring the clients to the ensemble down (i.e. prevent writes to pathRoot) to 'simulate' a snapshot behavior.

        Parameters:
        zk - the zookeeper handle
        pathRoot - The znode path, for which the entire subtree needs to be listed.
        Throws:
        java.lang.InterruptedException
        KeeperException