zookeeper error: Reason for KeeperErrorCode=NoChildrenForEphemerals

zookeeper错误:zookeeper.KeeperException$NoChildrenForEphemera: KeeperErrorCode = NoChildrenForEphemerals

 

When I build the parent node zookeeper.create(ZK_PATH, ZK_PATH.getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL), this error is reported.

Because I didn't study the parameters of create carefully, if the master node is temporary, its children cannot be built.

There are instructions at http://zookeeper.apache.org/doc/r3.2.2/api/org/apache/zookeeper/ZooKeeper.html, pasted below.

 

 

create

public String create(String path,
                     byte[] data,
                     List<ACL> acl,
                     CreateMode createMode)
              throws KeeperException,
                     InterruptedException

Create a node with the given path. The node data will be the given data, and node acl will be the given acl.

The flags argument specifies whether the created node will be ephemeral or not.

An ephemeral node will be removed by the ZooKeeper automatically when the session associated with the creation of the node expires.

The flags argument can also specify to create a sequential node. The actual path name of a sequential node will be the given path plus a suffix "_i" where i is the current sequential number of the node. Once such a node is created, the sequential number will be incremented by one.

If a node with the same actual path already exists in the ZooKeeper, a KeeperException with error code KeeperException.NodeExists will be thrown. Note that since a different actual path is used for each invocation of creating sequential node with the same path argument, the call will never throw "file exists" KeeperException.

If the parent node does not exist in the ZooKeeper, a KeeperException with error code KeeperException.NoNode will be thrown.

An ephemeral node cannot have children. If the parent node of the given path is ephemeral, a KeeperException with error code KeeperException.NoChildrenForEphemerals will be thrown.

This operation, if successful, will trigger all the watches left on the node of the given path by exists and getData API calls, and the watches left on the parent node by getChildren API calls.

If a node is created successfully, the ZooKeeper server will trigger the watches on the path left by exists calls, and the watches on the parent of the node by getChildren calls.

The maximum allowable size of the data array is 1 MB (1,048,576 bytes). Arrays larger than this will cause a KeeperExecption to be thrown.

 

Parameters:

path - the path for the node

data - the initial data for the node

acl - the acl for the node

createMode - specifying whether the node to be created is ephemeral and/or sequential

Returns:

the actual path of the created node

Throws:

KeeperException - if the server returns a non-zero error code

KeeperException.InvalidACLException - if the ACL is invalid

InterruptedException - if the transaction is interrupted

IllegalArgumentException - if an invalid path is specified

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326132576&siteId=291194637