public class ZKUtil extends Object
Constructor and Description |
---|
ZKUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
deleteRecursive(ZooKeeper zk,
String pathRoot)
Recursively delete the node with the given path.
|
static void |
deleteRecursive(ZooKeeper zk,
String pathRoot,
AsyncCallback.VoidCallback cb,
Object ctx)
Recursively delete the node with the given path.
|
static List<String> |
listSubTreeBFS(ZooKeeper zk,
String pathRoot)
BFS Traversal of the system under pathRoot, with the entries in the list, in the
same order as that of the traversal.
|
static void |
visitSubTreeDFS(ZooKeeper zk,
String path,
boolean watch,
AsyncCallback.StringCallback cb)
Visits the subtree with root as given path and calls the passed callback with each znode
found during the search.
|
public static void deleteRecursive(ZooKeeper zk, String pathRoot) throws InterruptedException, KeeperException
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.
IllegalArgumentException
- if an invalid path is specifiedInterruptedException
KeeperException
public static void deleteRecursive(ZooKeeper zk, String pathRoot, AsyncCallback.VoidCallback cb, Object ctx) throws InterruptedException, KeeperException
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.
zk
- the zookeeper handlepathRoot
- the path to be deletedcb
- call back methodctx
- the context the callback method is called withIllegalArgumentException
- if an invalid path is specifiedInterruptedException
KeeperException
public static List<String> listSubTreeBFS(ZooKeeper zk, String pathRoot) throws KeeperException, InterruptedException
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.
zk
- the zookeeper handlepathRoot
- The znode path, for which the entire subtree needs to be listed.InterruptedException
KeeperException
public static void visitSubTreeDFS(ZooKeeper zk, String path, boolean watch, AsyncCallback.StringCallback cb) throws KeeperException, InterruptedException
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.
KeeperException
InterruptedException
Copyright © 2008–2019 The Apache Software Foundation. All rights reserved.