public class ZKIntegration extends Object implements org.apache.zookeeper.Watcher, Closeable
| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
log |
static int |
SESSION_TIMEOUT |
static String |
SVC_SLIDER |
static String |
SVC_SLIDER_USERS |
static String |
ZK_SERVICES
Base path for services
|
static String |
ZK_SLIDER
Base path for all Slider references
|
static String |
ZK_USERS |
static List<String> |
ZK_USERS_PATH_LIST |
| Modifier | Constructor and Description |
|---|---|
protected |
ZKIntegration(String zkConnection,
String username,
String clustername,
boolean canBeReadOnly,
boolean createClusterPath,
org.apache.zookeeper.Watcher watchEventHandler,
int sessionTimeout) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
String |
createPath(String parent,
String entry,
List<org.apache.zookeeper.data.ACL> acl,
org.apache.zookeeper.CreateMode createMode)
Create a path under a parent, don't care if it already exists
As the path isn't returned, this isn't the way to create sequentially
numbered nodes.
|
boolean |
delete(String path)
Delete a node, does not throw an exception if the path is not fond
|
boolean |
deleteRecursive(String path)
Recursively delete a node, does not throw exception if any node does not exist.
|
boolean |
exists(String path) |
boolean |
getAlive() |
String |
getClusterPath() |
List<String> |
getClusters()
Blocking enum of users
|
org.apache.zookeeper.data.Stat |
getClusterStat() |
boolean |
getConnected() |
String |
getConnectionString() |
org.apache.zookeeper.ZooKeeper.States |
getState() |
void |
init() |
static String |
mkClusterPath(String username,
String clustername)
Build the path to a cluster; exists once the cluster has come up.
|
void |
mkPath(List<String> paths,
List<org.apache.zookeeper.data.ACL> acl,
org.apache.zookeeper.CreateMode createMode)
Recursive path create
|
static String |
mkSliderUserPath(String username)
Build the path to a cluster; exists once the cluster has come up.
|
static ZKIntegration |
newInstance(String zkConnection,
String username,
String clustername,
boolean createClusterPath,
boolean canBeReadOnly,
org.apache.zookeeper.Watcher watchEventHandler,
int sessionTimeout)
Create an instance bonded to the specific closure
|
void |
process(org.apache.zookeeper.WatchedEvent event)
Event handler to notify of state events
|
org.apache.zookeeper.data.Stat |
stat(String path) |
String |
toString() |
public static String ZK_SERVICES
public static String ZK_SLIDER
public static String ZK_USERS
public static String SVC_SLIDER
public static String SVC_SLIDER_USERS
public static int SESSION_TIMEOUT
protected static final org.slf4j.Logger log
protected ZKIntegration(String zkConnection, String username, String clustername, boolean canBeReadOnly, boolean createClusterPath, org.apache.zookeeper.Watcher watchEventHandler, int sessionTimeout) throws IOException
IOExceptionpublic void init()
throws IOException
IOExceptionpublic static ZKIntegration newInstance(String zkConnection, String username, String clustername, boolean createClusterPath, boolean canBeReadOnly, org.apache.zookeeper.Watcher watchEventHandler, int sessionTimeout) throws IOException
zkConnection - username - clustername - canBeReadOnly - watchEventHandler - IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic String getConnectionString()
public String getClusterPath()
public boolean getConnected()
public boolean getAlive()
public org.apache.zookeeper.ZooKeeper.States getState()
public org.apache.zookeeper.data.Stat getClusterStat()
throws org.apache.zookeeper.KeeperException,
InterruptedException
org.apache.zookeeper.KeeperExceptionInterruptedExceptionpublic boolean exists(String path) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperExceptionInterruptedExceptionpublic org.apache.zookeeper.data.Stat stat(String path) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperExceptionInterruptedExceptionpublic void process(org.apache.zookeeper.WatchedEvent event)
process in interface org.apache.zookeeper.Watcherevent - public String createPath(String parent, String entry, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode) throws org.apache.zookeeper.KeeperException, InterruptedException
parent - parent dir. Must have a trailing / if entry!=null||emptyentry - entry -can be null or "", in which case it is not appendedacl - createMode - org.apache.zookeeper.KeeperExceptionInterruptedExceptionpublic void mkPath(List<String> paths, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode) throws org.apache.zookeeper.KeeperException, InterruptedException
paths - path listacl - acl listcreateMode - create modesorg.apache.zookeeper.KeeperExceptionInterruptedExceptionpublic List<String> getClusters() throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperExceptionInterruptedExceptionpublic boolean delete(String path) throws InterruptedException, org.apache.zookeeper.KeeperException
path - path to deleteInterruptedExceptionorg.apache.zookeeper.KeeperExceptionpublic boolean deleteRecursive(String path) throws org.apache.zookeeper.KeeperException, InterruptedException
path - org.apache.zookeeper.KeeperExceptionInterruptedExceptionpublic static String mkClusterPath(String username, String clustername)
username - userclustername - name of the clusterCopyright © 2014–2015 The Apache Software Foundation. All rights reserved.