Package org.apache.pulsar.zookeeper
Class ZkUtils
- java.lang.Object
-
- org.apache.pulsar.zookeeper.ZkUtils
-
public final class ZkUtils extends java.lang.ObjectZooKeeper utils.
-
-
Constructor Summary
Constructors Constructor Description ZkUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancheckNodeAndWaitExpired(org.apache.zookeeper.ZooKeeper zk, java.lang.String path, long sessionTimeoutMs)Check if the provided path exists or not and wait it expired if possible.static java.lang.StringgetParentForPath(java.lang.String path)Returns the parent path of the provided path.
-
-
-
Method Detail
-
checkNodeAndWaitExpired
public static boolean checkNodeAndWaitExpired(org.apache.zookeeper.ZooKeeper zk, java.lang.String path, long sessionTimeoutMs) throws org.apache.zookeeper.KeeperException, java.lang.InterruptedExceptionCheck if the provided path exists or not and wait it expired if possible.- Parameters:
zk- the zookeeper client instancepath- the zookeeper pathsessionTimeoutMs- session timeout in milliseconds- Returns:
- true if path exists, otherwise return false
- Throws:
org.apache.zookeeper.KeeperException- when failed to access zookeeperjava.lang.InterruptedException- interrupted when waiting for znode to be expired
-
getParentForPath
public static java.lang.String getParentForPath(java.lang.String path)
Returns the parent path of the provided path. Works for UNIX-style paths only and is intended to be used for zookeeper paths. If you have a file system path usePaths.get(String, String...)andPath.getParent()instead.- Parameters:
path- the zookeeper path- Returns:
- the parent path or null if no parent exists
-
-