Zookeeper CreateMode

通过CreateMode 可以设置在zookeeper中创建节点的类型,节点类型共有4种:

EPHEMERAL:临时节点

EPHEMERAL_SEQUENTIAL:有序的临时节点

PERSISTENT:持久节点

PERSISTENT_SEQUENTIAL:有序的持久节点

   /**
     * The znode will not be automatically deleted upon client's disconnect.
     */
    PERSISTENT (0, false, false),

  客户端断开连接的时候,不会自动删除节点

    /**
    * The znode will not be automatically deleted upon client's disconnect,
    * and its name will be appended with a monotonically increasing number.
    */
    PERSISTENT_SEQUENTIAL (2, false, true)

  客户端断开连接的时候,不会自动删除节点,并且会将节点名拼接一个自增值,例如:创建节点时path输入的是test,当客户端退出时path将变成test0000000001,该值(0000000001)会自动增长!

 /**
     * The znode will be deleted upon the client's disconnect.
     */
    EPHEMERAL (1, true, false)

  客户端断开连接的时候,将会自定删除节点

    /**
     * The znode will be deleted upon the client's disconnect, and its name
     * will be appended with a monotonically increasing number.
     */
    EPHEMERAL_SEQUENTIAL (3, true, true);

  客户端断开连接的时候,将会自定删除几点,并且将节点名拼接一个自增值(同上)

原文地址:https://www.cnblogs.com/shiguotao-com/p/9368672.html