Class ZkUtils


  • public final class ZkUtils
    extends java.lang.Object
    ZooKeeper utils.
    • Constructor Summary

      Constructors 
      Constructor Description
      ZkUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean checkNodeAndWaitExpired​(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.String getParentForPath​(java.lang.String path)
      Returns the parent path of the provided path.
      • Methods inherited from class java.lang.Object

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

      • ZkUtils

        public ZkUtils()
    • 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.InterruptedException
        Check if the provided path exists or not and wait it expired if possible.
        Parameters:
        zk - the zookeeper client instance
        path - the zookeeper path
        sessionTimeoutMs - session timeout in milliseconds
        Returns:
        true if path exists, otherwise return false
        Throws:
        org.apache.zookeeper.KeeperException - when failed to access zookeeper
        java.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 use Paths.get(String, String...) and Path.getParent() instead.
        Parameters:
        path - the zookeeper path
        Returns:
        the parent path or null if no parent exists