public class KillSession
extends java.lang.Object
Utility to simulate a ZK session dying. See: ZooKeeper FAQ
In the case of testing we want to cause a problem, so to explicitly expire a session an application connects to ZooKeeper, saves the session id and password, creates another ZooKeeper handle with that id and password, and then closes the new handle. Since both handles reference the same session, the close on second handle will invalidate the session causing a SESSION_EXPIRED on the first handle.
Constructor and Description |
---|
KillSession() |
Modifier and Type | Method and Description |
---|---|
static void |
kill(org.apache.zookeeper.ZooKeeper client,
java.lang.String connectString)
Kill the given ZK session
|
static void |
kill(org.apache.zookeeper.ZooKeeper client,
java.lang.String connectString,
int maxMs)
Kill the given ZK session
|
public static void kill(org.apache.zookeeper.ZooKeeper client, java.lang.String connectString) throws java.lang.Exception
client
- the client to killconnectString
- server connection stringjava.lang.Exception
- errorspublic static void kill(org.apache.zookeeper.ZooKeeper client, java.lang.String connectString, int maxMs) throws java.lang.Exception
client
- the client to killconnectString
- server connection stringmaxMs
- max time ms to wait for killjava.lang.Exception
- errors