Hi Irfan, Does the ZooKeeper cluster that you want to run your clients against enable you to connect the servers via JMX? If yes then you could retrieve the list of clients connected to the server (via JMX) and then invoke terminateConnection or terminateSession on the connection of interest to you. https://github.com/apache/zookeeper/blob/branch-3.4/src/java/main/org/apache/zookeeper/server/ConnectionMXBean.java So, not exactly session expiration but might be of use. Regards, Guy
On Thu, Jun 23, 2016 at 5:02 PM, Jordan Zimmerman < [email protected]> wrote: > This is the old way to do it: > > > https://github.com/apache/curator/blob/master/curator-test/src/main/java/org/apache/curator/test/KillSession.java > > -Jordan > > > On Jun 23, 2016, at 8:46 AM, Irfan Hamid <[email protected]> wrote: > > > > Thanks Jordan. I'm currently using 3.4.6 so was hoping for a solution > > there. Secondly, the solution you've described would be suitable for > > unit-testing since it requires access to the ZooKeeper client object, or > am > > I missing something and we can inject a session expiration for a > different > > session than the one the client object is in? > > > > Thanks, > > Irfan. > > > > > > On Wed, Jun 22, 2016 at 1:21 PM, Jordan Zimmerman < > > [email protected]> wrote: > > > >> In ZK 3.5.x there is a method for this: > >> > >> client.getTestable().injectSessionExpiration(); > >> > >> -JZ > >> > >>> On Jun 22, 2016, at 3:18 PM, Irfan Hamid <[email protected]> > wrote: > >>> > >>> Hi, > >>> > >>> I'm testing some client code against a ZK cluster, and since it's local > >>> testing I can use a single ZK instance as well if need be. I'm trying > to > >>> simulate an expired connection so I can validate my reconnect logic. > I've > >>> tried the following: > >>> > >>> 1. Single ZK server: connect from client, then kill -9 zkpid (this > >> results > >>> in disconnect). Try waiting a long time then restart ZK server, it > >>> reconnects; > >>> 2. Multiple ZK server quorum: connect from client, then kill -9 zkpid > >> (the > >>> one client connected to). This causes the client to be disconnected and > >>> then connects to a different quorum server, until there is no majority > >> left > >>> active (1 out of 3) and then it can't reconnect. > >>> > >>> Is there an easy way for me to simulate an end-to-end scenario outside > of > >>> unit-tests that lets me see the behavior of my reconnect logic? > >>> > >>> Thanks, > >>> Irfan. > >> > >> > >
