Class ZooKeeperService
java.lang.Object
org.apache.zookeeper.server.jersey.ZooKeeperService
Singleton which provides JAX-RS resources access to the ZooKeeper client.
There's a single session for each base uri (so usually just one).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Close the ZooKeeper session and remove it from the internal mapsstatic void
Close the ZooKeeper session and remove itstatic void
closeAll()
Close all the ZooKeeper sessions and remove them from the internal mapsstatic ZooKeeper
Return a ZooKeeper client not tied to a specific session.static ZooKeeper
Return a ZooKeeper client for a session with a default expire timestatic ZooKeeper
Return a ZooKeeper client which may or may not be connected, but it will not be expired.static boolean
isConnected
(String contextPath, String session) Is there an active connection for this session?static void
mapContext
(String contextPath, Endpoint e) Specify ZooKeeper host:port for a particular context path.static void
resetTimer
(String contextPath, String session) Reset timer for a session
-
Constructor Details
-
ZooKeeperService
public ZooKeeperService()
-
-
Method Details
-
mapContext
Specify ZooKeeper host:port for a particular context path. The host:port string is passed to the ZK client, so this can be formatted with more than a single host:port pair. -
resetTimer
Reset timer for a session -
close
Close the ZooKeeper session and remove it from the internal maps -
close
Close the ZooKeeper session and remove it -
closeAll
public static void closeAll()Close all the ZooKeeper sessions and remove them from the internal maps -
isConnected
Is there an active connection for this session? -
getClient
Return a ZooKeeper client not tied to a specific session.- Throws:
IOException
-
getClient
Return a ZooKeeper client for a session with a default expire time- Throws:
IOException
-
getClient
public static ZooKeeper getClient(String contextPath, String session, int expireTime) throws IOException Return a ZooKeeper client which may or may not be connected, but it will not be expired. This method can be called multiple times, the same object will be returned except in the case where the session expires (at which point a new session will be returned)- Throws:
IOException
-