zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Johnson <willjohnsonsea...@gmail.com>
Subject Testing SessionExipred based on FAQ
Date Thu, 21 Jul 2011 20:36:36 GMT
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