Take a look at the docs, in particular information on sessions: http://zookeeper.apache.org/doc/r3.3.3/zookeeperProgrammers.html#ch_zkSessions "One of the parameters to the ZooKeeper client library call to create a ZooKeeper session is the session timeout in milliseconds. The client sends a requested timeout, the server responds with the timeout that it can give the client. The current implementation requires that the timeout be a minimum of 2 times the tickTime (as set in the server configuration) and a maximum of 20 times the tickTime. The ZooKeeper client API allows access to the negotiated timeout."
You can change the max limit imposed by the server, see here: http://zookeeper.apache.org/doc/r3.3.3/zookeeperAdmin.html#sc_advancedConfiguration You should be able to see in the logs what the negotiated session timeout was. This likely indicates that your client is pausing for long periods of time -- the most common case is GC pause. See the troubleshooting guide. https://cwiki.apache.org/confluence/display/ZOOKEEPER/Troubleshooting try turning on verbose GC logging to verify. Patrick On Fri, Sep 23, 2011 at 2:49 PM, Yuhan Zhang <[email protected]> wrote: > Hi all, > > I set the sessionTimeout value to be "Integer.MAX_VALUE" to the constructor > as > zooKeeper = new ZooKeeper(host, Integer.MAX_VALUE, this); > but reached an "session expired" exception when requesting a create > operation twice on the following line: > > lockPath = zooKeeper.create( lockFolder + "/0", new byte[0], > Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL); > > Exception: > org.apache.zookeeper.KeeperException$SessionExpiredException : > KeeperErrorCode = Session expired for /_lock/0 > > > why does this happen? could anyone give some advice? > > > Thank you. > > Yuhan >
