|
SMILA 1.0 API documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.smila.zookeeper.ZkConnection
public class ZkConnection
wrapper of ZooKeeper client that executes a number of ZooKeeper operation with handling for ConnectionLoss errors.
Field Summary | |
---|---|
static byte[] |
NO_DATA
use this constant for the data argument to create empty nodes. |
Constructor Summary | |
---|---|
ZkConnection(ZooKeeperService service)
create instance using the given service to get ZooKeeper clients when needed. |
Method Summary | |
---|---|
void |
createNode(java.lang.String nodePath,
byte[] data)
create a persistent node with given data. |
void |
createNode(java.lang.String nodePath,
byte[] data,
CreateMode mode)
create a node with given data. |
void |
createPath(java.lang.String nodePath,
byte[] data)
create a persistent node with given data. |
void |
deleteNode(java.lang.String nodePath)
delete the given node. |
void |
deleteTree(java.lang.String nodePath)
delete a complete node subtree, starting from the given path. |
void |
disconnectZkSession()
Close current zookeeper client (session). |
void |
ensurePathExists(java.lang.String path)
|
Stat |
exists(java.lang.String nodePath)
Check if node exists. |
Stat |
exists(java.lang.String nodePath,
Watcher watcher)
Check if node exists and set a watcher. |
java.util.List<java.lang.String> |
getChildrenSorted(java.lang.String nodePath)
get children from node, sorted by name. |
byte[] |
getData(java.lang.String nodePath)
get data of node. |
byte[] |
getData(java.lang.String nodePath,
Stat stat)
get data and stat of node. |
long |
getSessionId()
|
Stat |
setData(java.lang.String nodePath,
byte[] nodeData)
update data on existing node. |
Stat |
setData(java.lang.String nodePath,
byte[] nodeData,
int version)
update data on existing node if version does match. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte[] NO_DATA
Constructor Detail |
---|
public ZkConnection(ZooKeeperService service)
service
- ZooKeeper service.Method Detail |
---|
public long getSessionId()
public void createNode(java.lang.String nodePath, byte[] data) throws KeeperException
nodePath
- path for node to createdata
- data of node to create
KeeperException
- errorpublic void createNode(java.lang.String nodePath, byte[] data, CreateMode mode) throws KeeperException
nodePath
- path for node to createdata
- data of node to createmode
- 'PERSISTENT' if we want a persistent node, 'EPHEMERAL' if we want an ephemeral node
KeeperException
- errorpublic void createPath(java.lang.String nodePath, byte[] data) throws KeeperException
nodePath
- path for node to createdata
- data of node to create
KeeperException
- errorpublic void ensurePathExists(java.lang.String path) throws KeeperException
path
- the path whose elements should be created as zookeeper nodes if not existent
KeeperException
- error creating zookeeper nodespublic void deleteNode(java.lang.String nodePath) throws KeeperException
nodePath
- path for node to delete
KeeperException
- KeeperException.NoNodeException if node doesn't existpublic void deleteTree(java.lang.String nodePath) throws KeeperException
nodePath
- root node of tree to delete
KeeperException
- error deleting tree. State of subtree is quite undefined afterwards.public Stat exists(java.lang.String nodePath) throws KeeperException
nodePath
- path for node to check existence
KeeperException
- errorpublic Stat exists(java.lang.String nodePath, Watcher watcher) throws KeeperException
nodePath
- path for node to check existence
KeeperException
- errorpublic Stat setData(java.lang.String nodePath, byte[] nodeData, int version) throws KeeperException
nodePath
- path for node to update datanodeData
- new dataversion
- the expected matching version
KeeperException
- KeeperException.NoNodeException if node doesn't existpublic Stat setData(java.lang.String nodePath, byte[] nodeData) throws KeeperException
nodePath
- path for node to update datanodeData
- new data
KeeperException
- KeeperException.NoNodeException if node doesn't existpublic byte[] getData(java.lang.String nodePath) throws KeeperException
nodePath
- the node path to get the data
KeeperException
- KeeperException.NoNodeException if node doesn't existpublic byte[] getData(java.lang.String nodePath, Stat stat) throws KeeperException
nodePath
- the node path to get the datastat
- contains the stat of the node after the call
KeeperException
- KeeperException.NoNodeException if node doesn't existpublic java.util.List<java.lang.String> getChildrenSorted(java.lang.String nodePath) throws KeeperException
nodePath
- path of node to get the children
KeeperException
- KeeperException.NoNodeException if node doesn't existpublic void disconnectZkSession() throws java.io.IOException, ClusterConfigException
java.io.IOException
ClusterConfigException
|
SMILA 1.0 API documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |