zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Hunt <ph...@apache.org>
Subject Re: session expiration testing
Date Wed, 04 May 2011 16:36:14 GMT
On Tue, May 3, 2011 at 5:35 PM, Ted Dunning <ted.dunning@gmail.com> wrote:
> I have built an HA component that includes handling for session expiration.
>  I would like to test that code.
>
> This FAQ seems to imply that this is simple:
>
> http://wiki.apache.org/hadoop/ZooKeeper/FAQ#A4
>
> Based on that, I do this:
>
>    ZooKeeper keeper = lm.getZk();
>    ZooKeeper zkClone = new ZooKeeper("localhost:" + zkPort, 0, new
> Watcher() {
>      @Override
>      public void process(WatchedEvent event) {
>        // ignore
>      }
>    }, keeper.getSessionId(), keeper.getSessionPasswd());
>    zkClone.close();
>
> The lm object is my HA thing-thing.  This seems plausibly correct based on
> the FAQ answer, but then I do this:
>
>    keeper.getChildren("/", false);

A couple guesses:

How long are you waiting btw closing zkclone and doing the getchildren
on keeper? Specifically, are you waiting for the notification to come
back to keeper that it's session is expired?

"session moved" was added in 3.3, and iirc some fixes applied to it in
3.3.1+ (Ben worked on this and might be able to provide better
commentary than I). The specific change I'm thinking about is that
when a session was "moved" we now close the socket immediately. I'm
wondering if this is causing some issues in your specific test.

I'd suggest you log/system.out in your 2 watchers, run the test and
see what's really happening there.

Patrick

>
> I would expect that this would throw a session expired exception.
>
> It does not.
>
> The server that I am using was started in the before class part of the test:
>
>    zs = new ZooKeeperServer(tmpdir, tmpdir, 1000);
>    SyncRequestProcessor.setSnapCount(150);
>    NIOServerCnxn.Factory f = new NIOServerCnxn.Factory(new
> InetSocketAddress(zkPort));
>    f.startup(zs);
>    log.info("starting up the zookeeper server .. waiting");
>    Assert.assertTrue("waiting for server being up", waitForServerUp(zkPort,
> 2000));
>
> This is code that I stole from the ZK test classes and it seems to work for
> my other tests.
>
> My questions are:
>
> a) did I misread the FAQ?
>
> b) is the FAQ correct?
>
> c) is there an obvious and silly error in my code?
>
> d) WTF?
>
> Anybody have any thoughts?
>

Mime
View raw message