Class CuratorUtils


  • public class CuratorUtils
    extends Object
    • Field Detail

      • DEFAULT_MAX_ZNODE_BYTES

        public static final int DEFAULT_MAX_ZNODE_BYTES
        See Also:
        Constant Field Values
    • Constructor Detail

      • CuratorUtils

        public CuratorUtils()
    • Method Detail

      • createIfNotExists

        public static void createIfNotExists​(org.apache.curator.framework.CuratorFramework curatorFramework,
                                             String path,
                                             org.apache.zookeeper.CreateMode mode,
                                             byte[] rawBytes,
                                             int maxZnodeBytes)
                                      throws Exception
        Create znode if it does not already exist. If it does already exist, this does nothing. In particular, the existing znode may have a different payload or create mode.
        Parameters:
        curatorFramework - curator
        path - path
        mode - create mode
        rawBytes - payload
        maxZnodeBytes - maximum payload size
        Throws:
        IllegalArgumentException - if rawBytes.length > maxZnodeBytes
        Exception - if Curator throws an Exception
      • createOrSet

        public static void createOrSet​(org.apache.curator.framework.CuratorFramework curatorFramework,
                                       String path,
                                       org.apache.zookeeper.CreateMode mode,
                                       byte[] rawBytes,
                                       int maxZnodeBytes)
                                throws Exception
        Create znode if it does not already exist. If it does already exist, update the payload (but not the create mode). If someone deletes the znode while we're trying to set it, just let it stay deleted.
        Parameters:
        curatorFramework - curator
        path - path
        mode - create mode
        rawBytes - payload
        maxZnodeBytes - maximum payload size
        Throws:
        IllegalArgumentException - if rawBytes.length > maxZnodeBytes
        Exception - if Curator throws an Exception
      • isChildAdded

        public static boolean isChildAdded​(org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent event)