I saw that wiki page. And I read this paragraph "It means that the client
was partitioned off from the ZooKeeper service for more the the session
timeout ..."
That's why I use Expired event for cluster membership. In my case client is
a node in a cluster.

2010/2/9 Patrick Hunt <ph...@apache.org>

> this? "How should I handle SESSION_EXPIRED?"
> http://wiki.apache.org/hadoop/ZooKeeper/FAQ#A3
>
>
> Benjamin Reed wrote:
>
>> i was looking through the docs to see if we talk about handling session
>> expired, but i couldn't find anything. we should probably open a jira to add
>> to the docs, unless i missed something. did i?
>>
>> ben
>>
>> -----Original Message-----
>> From: Mahadev Konar [mailto:maha...@yahoo-inc.com] Sent: Monday, February
>> 08, 2010 2:43 PM
>> To: zookeeper-user@hadoop.apache.org
>> Subject: Re: When session expired event fired?
>>
>> Hi,
>>  a zookeeper client does not expire a session until and unless it is able
>> to
>> connect to one of the servers. In your case if you kill all the servers,
>> the
>> client is not able to connect to any of the servers and will keep trying
>> to
>> connect to the three servers. It cannot expire a session on its own and
>> needs to hear from the server to know if the session is expired or not.
>>
>> Does that help?
>> Thanks
>> mahadev
>>
>>
>> On 2/8/10 2:37 PM, "neptune" <opennept...@gmail.com> wrote:
>>
>>  Hi all.
>>> I have a question. I started zookeeper(3.2.2) on three servers.
>>> When session expired event fired in following code?
>>> I expected that if client can't connect to server(disconnected) for
>>> session
>>> timeout, zookeeper fires session expired event.
>>> I killed three zookeeper server sequentially. Client retry to connect
>>> zookeeper server. Never occured Expired event.
>>>
>>> *class WatcherTest {
>>>  public static void main(String[] args) {
>>>    (new **WatcherTest*()).exec();
>>> *  }
>>>
>>>  private WatcherTest() throws Exception {
>>>    zk = new ZooKeeper("server1:2181,server2:2181:server3:2181", 10 *
>>> 1000,
>>> this);
>>>  }
>>>  private void exec() {
>>>    while(ture) {
>>>      //do something
>>>    }
>>>  }
>>>  public void process(WatchedEvent event) {
>>>    if (event.getType() == Event.EventType.None) {
>>>      switch (event.getState()) {
>>>      case SyncConnected:
>>>        System.out.println("ZK SyncConnected");
>>>        break;
>>>      case Disconnected:
>>>        System.out.println("ZK Disconnected");
>>>        break;
>>>      case Expired:
>>>        System.out.println("ZK Session Expired");
>>>        System.exit(0);
>>>        break;
>>>      }
>>>    }
>>> }
>>> *
>>>
>>
>>

Reply via email to