You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Ye...@gmail.com on 2009/09/29 09:23:25 UTC
How to reconnect server when the session expired?
Hi all:
When used Zookeeper in my project, I noticed a problem about the session.
When a session expired, the io thread of the client just return,
void *do_io(void *v)
{
...
while(!zh->close_requested) {
if(is_unrecoverable(zh))
break;
}
...
}
However, in my scenario, I want to reconnect to the Zookeeper Server and
recover the watcher which have been set for the last session. How to do it?
Just close the last zookeeper handler and init a new one, and add all the
watchers again? Is there a more efficient way?
Thanks!
Re: How to reconnect server when the session expired?
Posted by Patrick Hunt <ph...@apache.org>.
When the session expires your only option is to create a new session and
re-register the watches, re-create ephemerals, etc...
Patrick
YeQian.ZJU@gmail.com wrote:
> Hi all:
>
> When used Zookeeper in my project, I noticed a problem about the
> session. When a session expired, the io thread of the client just return,
> void *do_io(void *v)
> {
> ...
> while(!zh->close_requested) {
> if(is_unrecoverable(zh))
> break;
> }
> ...
> }
>
> However, in my scenario, I want to reconnect to the Zookeeper Server and
> recover the watcher which have been set for the last session. How to do
> it? Just close the last zookeeper handler and init a new one, and add
> all the watchers again? Is there a more efficient way?
>
> Thanks!
>