close the underlying zk connection
Create a path with OPEN_ACL_UNSAFE hardcoded
Create a node and then return it.
Create a node and then return it. Under the hood this is a create followed by a get. If the stat or data is not needed use a plain create which is cheaper.
Recursively create a path with persistent nodes and no watches set.
Wrapper around zk delete method.
Wrapper around zk delete method.
Delete all children of this node
The version only applies to the node indicated by the path. If force is true all children will be deleted even if the version doesn't match.
Delete all the children of a node but not the node.
Wrapper around the ZK exists method.
Wrapper around the ZK exists method. Watch is hardcoded to false.
Wrapper around zk getData method.
Wrapper around zk getData method. Watch is hardcoded to false.
Wrapper around the ZK getChildren method.
Wrapper around the ZK getChildren method. Watch is hardcoded to false.
Return the node if it exists, otherwise create a new node with the data passed in.
Return the node if it exists, otherwise create a new node with the data passed in. If the node is created a get will be called and the value returned. In case of a race condition where a two or more requests are executed at the same time and one of the creates will fail with a NodeExistsException, it will be handled and a get will be called.
helper method to convert a zk response in to a client reponse and handle the errors
Checks the connection by checking existence of "/"
Check the connection synchronously
Wrapper around the zk setData method.
Wrapper around the zk setData method.
Given a string representing a path, return each subpath Ex.
Given a string representing a path, return each subpath Ex. subPaths("/a/b/c", "/") == ["/a", "/a/b", "/a/b/c"]
get the underlying ZK connection
set a persistent watch on if the children of this node change.
set a persistent watch on if the children of this node change. If they do the updated ChildResponse will be returned.
@return
Sets a persistent child watch.
Sets a persistent child watch.
watchChildren
sets the client watcher.
sets the client watcher. reconnecting on session expired is handled by the client and doesn't need to be handled here.
set a persistent watch on a node listening for data changes.
set a persistent watch on a node listening for data changes. If a NodeDataChanged event is received or a NodeCreated event is received the DataResponse will be returned with the new data and the watch will be reset. If a None or NodeChildrenChanged the watch will be reset returning nothing. If the node is deleted receiving a NodeDeleted event None will be returned.
In the event of an error nothing will be returned but errors will be logged.
relative or absolute
if this is false the watch will not be reset after receiving an event. ( normal zk behavior )
callback executed on data events. None on node deleted event. path will always be absolute regardless of what is passed into the function
initial data. If this returns successfully the watch was set otherwise it wasn't
Set a persistent watch on data.
Set a persistent watch on data.
watchData
Scala wrapper around the async ZK api. This is based on the twitter scala wrapper now maintained by 4square. https://github.com/foursquare/scala-zookeeper-client
It uses Akka 2.0 Futures. Once our company gets on scala 2.10 I will refactor to use SIP 14 Futures.
I didn't implement any ACL stuff because I never use that shiz.
You can pass in a base path (defaults to "/") which will be prepended to any path that does not start with a "/". This allows you to specify a context to all requests. Absolute paths, those starting with "/", will not have the base path prepended.
On connection the base path will be created if it does not already exist.