public class ZookeeperSession extends Object implements ClusterInfoSession, DisruptibleSession
| Modifier and Type | Class and Description |
|---|---|
protected class |
ZookeeperSession.WatcherProxy |
protected static class |
ZookeeperSession.ZkWatcher |
| Modifier and Type | Field and Description |
|---|---|
protected String |
connectString |
protected long |
resetDelay |
protected int |
sessionTimeout |
| Modifier | Constructor and Description |
|---|---|
protected |
ZookeeperSession(Serializer serializer,
String connectString,
int sessionTimeout) |
| Modifier and Type | Method and Description |
|---|---|
void |
disrupt() |
boolean |
exists(String ppath,
ClusterInfoWatcher watcher)
Check if a path has already been created.
|
Object |
getData(String ppath,
ClusterInfoWatcher watcher)
If data is stored at the node indicated by the path, then the data will be returned.
|
Collection<String> |
getSubdirs(String ppath,
ClusterInfoWatcher pwatcher)
Show all of the subdirectories of the given directory.
|
protected ZookeeperSession.WatcherProxy |
makeWatcherProxy(ClusterInfoWatcher watcher) |
protected org.apache.zookeeper.ZooKeeper |
makeZooKeeperClient(String connectString,
int sessionTimeout)
This is defined here to be overridden in a test.
|
String |
mkdir(String path,
Object data,
DirMode mode)
This will create a node at the given path.
|
void |
rmdir(String ppath)
This will remove the directory stored at the path.
|
void |
setData(String ppath,
Object info)
Set the data associated with the tree node identified by the path.
|
void |
stop()
Stop the session.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, recursiveMkdirprotected long resetDelay
protected String connectString
protected int sessionTimeout
protected ZookeeperSession(Serializer serializer, String connectString, int sessionTimeout) throws IOException
IOExceptionpublic String mkdir(String path, Object data, DirMode mode) throws ClusterInfoException
ClusterInfoSessionmkdir in interface ClusterInfoSessionpath - a '/' separated path to a directory in the cluster information manager to create.data - optional data to set for that directorymode - is the mode to set for the new directory. See DirMode.null if the directory cannot be created
or already exists. If the DirMode is sequential then the result will satisfy the SEQUENTIAL
requirements (see DirMode for the details).ClusterInfoException - on an error which can include the fact that the parent directory doesn't exist (when it
should throw a ClusterInfoException.NoParentException) or if you add a directory as a subdir of an
EPHEMERAL directory.public void rmdir(String ppath) throws ClusterInfoException
ClusterInfoSessionrmdir in interface ClusterInfoSessionppath - is the directory to delete.ClusterInfoException - if there is no node at the given path.public boolean exists(String ppath, ClusterInfoWatcher watcher) throws ClusterInfoException
ClusterInfoSessionexists in interface ClusterInfoSessionppath - is the directory to checkwatcher - if non-null, and the path exists, then the watcher will be called back whenever the node at the path has data added to it, or is deleted.ClusterInfoException - if there is an unforeseen problem.public Object getData(String ppath, ClusterInfoWatcher watcher) throws ClusterInfoException
ClusterInfoSessiongetData in interface ClusterInfoSessionppath - place to put the data.watcher - if non-null, and the path exists, then the watcher will be called back whenever the node at the path has data added to it, or is deleted.ClusterInfoExceptionpublic void setData(String ppath, Object info) throws ClusterInfoException
ClusterInfoSessionsetData in interface ClusterInfoSessionppath - identify the directory/tree node of the place to store the datainfo - the data to put at the given location.ClusterInfoExceptionpublic Collection<String> getSubdirs(String ppath, ClusterInfoWatcher pwatcher) throws ClusterInfoException
ClusterInfoSessiongetSubdirs in interface ClusterInfoSessionppath - where the subdirectories to show are.pwatcher - if non-null, and the path exists, then the watcher will be called back whenever the node at the path has data added to it, or is deleted.ClusterInfoExceptionpublic void stop()
ClusterInfoSessionstop in interface ClusterInfoSessionpublic void disrupt()
disrupt in interface DisruptibleSessionprotected org.apache.zookeeper.ZooKeeper makeZooKeeperClient(String connectString, int sessionTimeout) throws IOException
IOExceptionprotected ZookeeperSession.WatcherProxy makeWatcherProxy(ClusterInfoWatcher watcher)
Copyright © 2018. All rights reserved.