Enum CreateOption

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<CreateOption>

    public enum CreateOption
    extends java.lang.Enum<CreateOption>
    Options when creating ZNodes
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      compress
      Cause the data to be compressed using the configured compression provider
      createParentsAsContainers
      Causes any parent nodes to get created using CreateMode.CONTAINER if they haven't already been.
      createParentsIfNeeded
      Causes any parent nodes to get created if they haven't already been
      doProtected
      Hat-tip to https://github.com/sbridges for pointing this out
      setDataIfExists
      If the ZNode already exists, Curator will instead call setData()
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static CreateOption valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static CreateOption[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • createParentsIfNeeded

        public static final CreateOption createParentsIfNeeded
        Causes any parent nodes to get created if they haven't already been
      • createParentsAsContainers

        public static final CreateOption createParentsAsContainers
        Causes any parent nodes to get created using CreateMode.CONTAINER if they haven't already been. IMPORTANT NOTE: container creation is a new feature in recent versions of ZooKeeper. If the ZooKeeper version you're using does not support containers, the parent nodes are created as ordinary PERSISTENT nodes.
      • doProtected

        public static final CreateOption doProtected

        Hat-tip to https://github.com/sbridges for pointing this out

        It turns out there is an edge case that exists when creating sequential-ephemeral nodes. The creation can succeed on the server, but the server can crash before the created node name is returned to the client. However, the ZK session is still valid so the ephemeral node is not deleted. Thus, there is no way for the client to determine what node was created for them.

        Even without sequential-ephemeral, however, the create can succeed on the sever but the client (for various reasons) will not know it.

        Putting the create builder into protection mode works around this. The name of the node that is created is prefixed with a GUID. If node creation fails the normal retry mechanism will occur. On the retry, the parent path is first searched for a node that has the GUID in it. If that node is found, it is assumed to be the lost node that was successfully created on the first try and is returned to the caller.

      • compress

        public static final CreateOption compress
        Cause the data to be compressed using the configured compression provider
      • setDataIfExists

        public static final CreateOption setDataIfExists
        If the ZNode already exists, Curator will instead call setData()
    • Method Detail

      • values

        public static CreateOption[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CreateOption c : CreateOption.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CreateOption valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null