-Re: How to recover previous watcher & event after "session expired"
Martin Kou 2012-05-19, 21:31
Correct. And even simple connection losses can cause watches to become
unreliable as well:
"One caveat to the watch management: it is possible to miss an event for
the creation and deletion of a znode if watching for creation and both the
create and delete happens while the client is disconnected from ZooKeeper."
On Fri, May 18, 2012 at 8:33 PM, 李赫元 <[EMAIL PROTECTED]> wrote:
> Thanks for your help.
> That means we can't totally rely on watchs because it may loss event if
> session expired, right?
> 在 2012年5月19日星期六，Camille Fournier <[EMAIL PROTECTED]> 写道：
> > I'm not sure what you mean in question #1. A session expired event
> > generally causes the client to become completely invalid, you could
> > wrap the client in your own logic to record what you were watching,
> > but I don't think you can get that out of the client after it's
> > expired.
> > 2. You won't be able to see events that happened when the session was
> > expired. The server has closed your connection and won't know to send
> > you events unless you have a valid session with a valid watch.
> > 3. Reconnect won't work on expired sessions, you need to create an
> > entirely new session. Reconnect works when you get disconnected but
> > not expired.
> > Hope that helps
> > On Fri, May 18, 2012 at 12:18 PM, 李赫元 <[EMAIL PROTECTED]> wrote:
> >> Hi, All
> >> I'm dealing with the case of "session expired" event. Please help me
> >> with the following question.
> >> 1. After receive "session expired" event, how to recover the watch
> >> that are setting before expired gracefully?
> >> 2.Currently, I record the watch setting and call the api to set it
> >> again after I got "expired event". It will callback for event after
> >> connection was success again. But what about the event happend between
> >> I success reinit the session to zk server. Currently, it got lost. Is
> >> there any way that I can got these events ?
> >> 3.I try to use reconnect, in zookeeper_init, but does't work. My guess
> >> is reconnect is only work for connection that are in state connect
> >> (Not valid after session timeout), is it right?
> >> Thanks for your help !