Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Zookeeper, mail # user - Is there an easy way to expire a session for testing?


Copy link to this message
-
Is there an easy way to expire a session for testing?
Ben.Young@... 2014-01-14, 15:14
Hi

Apologies for delibaratly reusing an FAQ item as the title of the question, but it's when I'm trying to implement the suggestion that I'm having issues! I'm currently using the latest C# client, but the code looks identical in the Java client, so it may be applicable to both.

I'm trying to reconnect to an existing session using the session id and password in order to force an expiry in a unit test. The connection works ok, but actually forcing the expiry seems very flaky. The problem seems to occur at the line:

                        SubmitRequest(new RequestHeader { Type = (int)OpCode.CloseSession }, null, null, null);

Or

            RequestHeader h = new RequestHeader();
            h.setType(ZooDefs.OpCode.closeSession);

            submitRequest(h, null, null, null);

in the Java case. In many cases the client is in the state CONNECTION_LOST (which seems ok, as it normally reconnects?), so the send fails, but as the client is in the process of shutting down, it's not resent, and so the server never gets the explicit expiry, which means the original connection never gets a SessionExpired error. Is there a unit test anywhere in the codebase that shows how to implement tests like this reliably? I've even tried performing the session expiry in a separate process, but this doesn't appear to work reliably either

Thanks,
Ben