public interface ZKClient
Modifier and Type | Method and Description |
---|---|
Cancellable |
addConnectionWatcher(org.apache.zookeeper.Watcher watcher)
Adds a
Watcher that will be called whenever connection state change. |
OperationFuture<String> |
create(String path,
byte[] data,
org.apache.zookeeper.CreateMode createMode)
Creates a path in zookeeper.
|
OperationFuture<String> |
create(String path,
byte[] data,
org.apache.zookeeper.CreateMode createMode,
boolean createParent)
Creates a path in zookeeper.
|
OperationFuture<String> |
create(String path,
byte[] data,
org.apache.zookeeper.CreateMode createMode,
boolean createParent,
Iterable<org.apache.zookeeper.data.ACL> acl)
Creates a path in zookeeper, with given data and create mode.
|
OperationFuture<String> |
create(String path,
byte[] data,
org.apache.zookeeper.CreateMode createMode,
Iterable<org.apache.zookeeper.data.ACL> acl)
Creates a path in zookeeper.
|
OperationFuture<String> |
delete(String path)
Deletes the node of the given path without matching version.
|
OperationFuture<String> |
delete(String deletePath,
int version)
Deletes the node of the given path that match the given version.
|
OperationFuture<org.apache.zookeeper.data.Stat> |
exists(String path)
Checks if the path exists.
|
OperationFuture<org.apache.zookeeper.data.Stat> |
exists(String path,
org.apache.zookeeper.Watcher watcher)
Checks if the given path exists and leave a watcher on the node for watching creation/deletion/data changes
on the node.
|
OperationFuture<ACLData> |
getACL(String path)
Retrieves the Stat and ACL being set at the given path.
|
OperationFuture<NodeChildren> |
getChildren(String path)
Gets the list of children nodes under the given path.
|
OperationFuture<NodeChildren> |
getChildren(String path,
org.apache.zookeeper.Watcher watcher)
Gets the list of children nodes under the given path and leave a watcher on the node for watching node
deletion and children nodes creation/deletion.
|
String |
getConnectString()
Returns the connection string used for connecting to Zookeeper.
|
OperationFuture<NodeData> |
getData(String path)
Gets the data stored in the given path.
|
OperationFuture<NodeData> |
getData(String path,
org.apache.zookeeper.Watcher watcher)
Gets the data stored in the given path and leave a watcher on the node for watching deletion/data changes on
the node.
|
Long |
getSessionId()
Returns the current Zookeeper session ID of this client.
|
OperationFuture<org.apache.zookeeper.data.Stat> |
setACL(String path,
Iterable<org.apache.zookeeper.data.ACL> acl)
Sets the ACL of the given path if the path exists.
|
OperationFuture<org.apache.zookeeper.data.Stat> |
setACL(String path,
Iterable<org.apache.zookeeper.data.ACL> acl,
int version)
Sets the ACL of the given path if the path exists and version matched.
|
OperationFuture<org.apache.zookeeper.data.Stat> |
setData(String path,
byte[] data)
Sets the data for the given path without matching version.
|
OperationFuture<org.apache.zookeeper.data.Stat> |
setData(String dataPath,
byte[] data,
int version)
Sets the data for the given path that match the given version.
|
Long getSessionId()
null
is returned.String getConnectString()
Cancellable addConnectionWatcher(org.apache.zookeeper.Watcher watcher)
Watcher
that will be called whenever connection state change.watcher
- The watcher to set.Cancellable
for removing the watcherOperationFuture<String> create(String path, @Nullable byte[] data, org.apache.zookeeper.CreateMode createMode)
create(path, data, createMode, true)
.OperationFuture<String> create(String path, @Nullable byte[] data, org.apache.zookeeper.CreateMode createMode, boolean createParent)
create(path, data, createMode, createParent, ZooDefs.Ids.OPEN_ACL_UNSAFE)
OperationFuture<String> create(String path, @Nullable byte[] data, org.apache.zookeeper.CreateMode createMode, Iterable<org.apache.zookeeper.data.ACL> acl)
create(path, data, createMode, true, acl)
OperationFuture<String> create(String path, @Nullable byte[] data, org.apache.zookeeper.CreateMode createMode, boolean createParent, Iterable<org.apache.zookeeper.data.ACL> acl)
path
- Path to be createddata
- Data to be stored in the node, or null
if no data to store.createMode
- The CreateMode
for the node.createParent
- If true
and parent nodes are missing, it will create all parent nodes as normal
persistent node with the ACL ZooDefs.Ids.OPEN_ACL_UNSAFE
before creating the request node.acl
- Set of ACL
to be set for the node being created.OperationFuture
that will be completed when the
creation is done. If there is error during creation, it will be reflected as error in the future.OperationFuture<org.apache.zookeeper.data.Stat> exists(String path)
exists(path, null)
.OperationFuture<org.apache.zookeeper.data.Stat> exists(String path, @Nullable org.apache.zookeeper.Watcher watcher)
path
- The path to check for existence.watcher
- Watcher for watching changes, or null
if no watcher to set.OperationFuture
that will be completed when the exists check is done. If the path
does exists, the node Stat
is set into the future. If the path doesn't exists,
a null
value is set into the future.OperationFuture<NodeChildren> getChildren(String path)
getChildren(path, null)
.OperationFuture<NodeChildren> getChildren(String path, @Nullable org.apache.zookeeper.Watcher watcher)
path
- The path to fetch for children nodeswatcher
- Watcher for watching changes, or null
if no watcher to set.OperationFuture
that will be completed when the getChildren call is done, with the result
given as NodeChildren
. If there is error, it will be reflected as error in the future.OperationFuture<NodeData> getData(String path)
getData(path, null)
.OperationFuture<NodeData> getData(String path, @Nullable org.apache.zookeeper.Watcher watcher)
path
- The path to get data from.watcher
- Watcher for watching changes, or null
if no watcher to set.OperationFuture
that will be completed when the getData call is done, with the result
given as NodeData
. If there is error, it will be reflected as error in the future.OperationFuture<org.apache.zookeeper.data.Stat> setData(String path, byte[] data)
setData(path, data, -1)
.OperationFuture<org.apache.zookeeper.data.Stat> setData(String dataPath, byte[] data, int version)
-1
, it matches
any version.dataPath
- The path to set data to.data
- Data to be set.version
- Matching version.OperationFuture
that will be completed when the setData call is done, with node Stat
given as the future result. If there is error, it will be reflected as error in the future.OperationFuture<String> delete(String path)
delete(path, -1)
.delete(String, int)
OperationFuture<String> delete(String deletePath, int version)
-1
, it matches
any version.deletePath
- The path to set data to.version
- Matching version.OperationFuture
that will be completed when the setData call is done, with node path
given as the future result. If there is error, it will be reflected as error in the future.OperationFuture<ACLData> getACL(String path)
path
- The path to get information from.OperationFuture
that will be completed when the getACL call is done, with the result given as
ACLData
. If there is error, it will be reflected as error in the future.OperationFuture<org.apache.zookeeper.data.Stat> setACL(String path, Iterable<org.apache.zookeeper.data.ACL> acl)
setACL(path, acl, -1)
setACL(String, Iterable, int)
OperationFuture<org.apache.zookeeper.data.Stat> setACL(String path, Iterable<org.apache.zookeeper.data.ACL> acl, int version)
path
- The path to have ACL being set.acl
- ACL to set to.version
- Version of the node.OperationFuture
that will be completed when the setACL call is done, with the node Stat
available as the future result. If there is error, it will be reflected as error in the future.Copyright © 2013-2016 The Apache Software Foundation. All rights reserved.