Reputation: 10812
I want to know how to create persistent nodes in ZooKeeper
, using C++
client. I know from documentation, that there is a method zoo_acreate
. And documentation says about this method that:
This method will create a node in ZooKeeper. A node can only be created if it does not already exists. The Create Flags affect the creation of nodes. If ZOO_EPHEMERAL flag is set, the node will automatically get removed if the client session goes away. If the ZOO_SEQUENCE flag is set, a unique monotonically increasing sequence number is appended to the path name.
But, unfortunatelly, almost as always with C++ libraries, this library completely lacks reasonable teeny-weeny examples demonstarting the usage of the library methods. As for example in this case where documentation page is about zoo_acreate
method, but some terribly looking example is totally about something else (it does not even mention zoo_acreate
method).
So, my question is how to set these flags ZOO_EPHEMERAL
and ZOO_SEQUENCE
. It would be great to see this in the context of some tiny examples. Thanks!
Upvotes: 0
Views: 1148
Reputation: 4173
Googling for "zoo_acreate ZOO_EPHEMERAL" gave this as the seventh result:
string path = "/nodes/";
string value = "data";
int rc = zoo_acreate(zh, path.c_str(), value.c_str(), value.length(),
&ZOO_OPEN_ACL_UNSAFE, ZOO_EPHEMERAL | ZOO_SEQUENCE, &czoo_created, &where);
Source: https://issues.apache.org/jira/browse/ZOOKEEPER-348
Upvotes: 1