Utility functions for Zookeeper
Safely call a function while handling connection loss
Note
This function merely retries the query until an active Zookeeper session is available that returns without throwing a ConnectionLoss Exception. When creating a node, this could result in a NodeAlreadyExists exception because the create ran twice.
Safely creates an ephemeral sequence node using a UUID prefix
This function properly handles zookeeper ConnectionLoss exceptions and determines after waiting for reconnection whether it was created successfully.
Parameters: |
|
---|---|
Returns: | Name of the created node |
The name will be split so that its prefixed by the UUID and suffixed by the sequence.
Example:
>>> safe_create_ephemeral_sequence(zk, '/path/to/node/myname',
[ZOO_OPEN_ACL_UNSAFE])
'/path/to/node/dfad3fa294d745e499d883b0a38bbc93-myname-0001'