zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Johnson <willjohnsonsea...@gmail.com>
Subject Re: Testing SessionExipred based on FAQ
Date Fri, 22 Jul 2011 13:17:56 GMT
So give the ticket I created and ZOOKEEPER-710 how do i go about testing
session timeouts programmatically?

On Fri, Jul 22, 2011 at 8:57 AM, Will Johnson
<willjohnsonsearch@gmail.com>wrote:

> Created: https://issues.apache.org/jira/browse/ZOOKEEPER-1132
>
>
> On Thu, Jul 21, 2011 at 6:25 PM, Patrick Hunt <phunt@apache.org> wrote:
>
>> I think the FAQ is out of date, iirc it's probably due to this change
>> https://issues.apache.org/jira/browse/ZOOKEEPER-710
>> specifically
>> "the leader needs to drop the connection when it sees the MOVED error
>> so that the client can reestablish the session properly with another
>> machine"
>> which I believe you are seeing here.
>>
>> Also see this thread, there are other issues:
>> http://markmail.org/message/wqj347dlrsd74qya
>>
>> I would think though that zoo1 should eventually see the session
>> expiration - it will get disconnected but will then re-attempt to
>> connect to the server, at which point it will be notice the session is
>> expired.
>>
>> Would you mind entering a JIRA for this (to update the FAQ). Thanks!
>>
>> Patrick
>>
>> On Thu, Jul 21, 2011 at 1:36 PM, Will Johnson
>> <willjohnsonsearch@gmail.com> wrote:
>> > i'm trying to test SessionExpired based on the FAQ (
>> > http://wiki.apache.org/hadoop/ZooKeeper/FAQ)  can anyone point out why
>> i'm
>> > getting ConnectionLoss exceptions instead of SessionExpiredExceptions
>> based
>> > on the unit test below:
>> >
>> > @Test
>> >  public void testSimpleConnection() throws Exception {
>> >    String hostPort = "localhost:9999";
>> >    ZooKeeper zoo1 = new ZooKeeper(hostPort, 1000, null);
>> >
>> >    // just make sure we can talk to zookeeper
>> >    Assert.assertNull(zoo1.exists("/foo", false));
>> >    zoo1.create("/foo", null, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
>> >    Assert.assertNotNull(zoo1.exists("/foo", false));
>> >
>> >    // construct another client with the same id
>> >    ZooKeeper zoo2 = new ZooKeeper(hostPort, zoo1.getSessionTimeout(),
>> null,
>> > zoo1.getSessionId(), null);
>> >    // closing this session should invalidate the first:
>> > http://wiki.apache.org/hadoop/ZooKeeper/FAQ
>> >    zoo2.close();
>> >
>> >    // sleep just to make sure everything gets evicted
>> >    Thread.sleep(zoo1.getSessionTimeout() * 2);
>> >
>> >    // closing this session should invalidate the first:
>> > http://wiki.apache.org/hadoop/ZooKeeper/FAQ
>> >    // this is where i always get ConnectionLoss instead of
>> SessionExpired
>> >    Assert.assertNull(zoo1.exists("/foo", false));
>> >
>> >  }
>> >
>>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message