Return-Path: Delivered-To: apmail-hadoop-zookeeper-user-archive@minotaur.apache.org Received: (qmail 46201 invoked from network); 24 Jun 2010 20:26:34 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 24 Jun 2010 20:26:34 -0000 Received: (qmail 12480 invoked by uid 500); 24 Jun 2010 20:26:34 -0000 Delivered-To: apmail-hadoop-zookeeper-user-archive@hadoop.apache.org Received: (qmail 12367 invoked by uid 500); 24 Jun 2010 20:26:33 -0000 Mailing-List: contact zookeeper-user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: zookeeper-user@hadoop.apache.org Delivered-To: mailing list zookeeper-user@hadoop.apache.org Received: (qmail 12359 invoked by uid 99); 24 Jun 2010 20:26:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jun 2010 20:26:33 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of alexismidon@gmail.com designates 209.85.212.48 as permitted sender) Received: from [209.85.212.48] (HELO mail-vw0-f48.google.com) (209.85.212.48) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jun 2010 20:26:25 +0000 Received: by vws15 with SMTP id 15so1398936vws.35 for ; Thu, 24 Jun 2010 13:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=WdffE2RHD3C1CG5BOiiIb2JJbx8UUNlQ7FjJfJt00Ug=; b=Up3y9c2VsQ+n9Ev9o0xPXN3YC0hjl0k9CA3SnF37mMVEdRpfO8QBsvt/CE7DmOpKR4 ocsQZmmcdZL87ymcfhnBMq+hGfcW0JZx9bMbScvBgo+Q9iDqnJZPkMGBri2KAyqSoQDX PLeTeb1+C+Y2TEDJmfrJa3vxXAR+mcvfewK7E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=qgPGy9D6c5cDrR3gFB+Y0WRLyfVpk2C2TWsAQXnCjUUw/jR3MTFYpC01NCzFCMtSpF cuHuY6Pg3TrOBGwVbZD7Qv4KsjC3e8FoPiOmH6l5SxQkASREkCopUm7uz6kKiJOV8L05 X5caXxKg3jAqE2wUbssUWuAKjKyVGV/9SyXYE= Received: by 10.220.121.140 with SMTP id h12mr5282394vcr.170.1277411164258; Thu, 24 Jun 2010 13:26:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.13.137 with HTTP; Thu, 24 Jun 2010 13:25:44 -0700 (PDT) In-Reply-To: References: From: Alexis Midon Date: Thu, 24 Jun 2010 13:25:44 -0700 Message-ID: Subject: Re: Watchers & error handling To: zookeeper-user@hadoop.apache.org Content-Type: multipart/alternative; boundary=001636b14763ad81910489cc76d6 X-Virus-Checked: Checked by ClamAV on apache.org --001636b14763ad81910489cc76d6 Content-Type: text/plain; charset=UTF-8 Hi guys, could you confirm that the default watcher is always invoked for none-type events, even if the action set a different listener? thanks, Alexis On Sat, Jun 12, 2010 at 10:07 PM, Alexis Midon wrote: > Hi all, > > I implemented queues and locks on top of ZooKeeper, and I'm pretty happy so > far. Thanks for the nice work. Tests look good. So good that we can focus on > exception/error handling and I got a couple of questions. > > #1. Regarding the use of the default watcher. A ZooKeeper instance has a > default watcher, most operations can also specify a watcher. When both are > set, does the operation watcher override the default watcher? > or will both watchers be invoked? if so in which order? Does each watcher > receive all the types of event? > I had a look at the code, and my understanding is that the default watcher > will always receive the type-NONE events, even if an "operation" watcher is > set. No guarantee on the order of invocation though. Could you confirm > and/or complete please? > > #2 After a connection loss, the client will eventually reconnect to the ZK > cluster so I guess I can keep using the same client instance. But are there > cases where it is necessary to re-instantiate a ZooKeeper client? As a first > recovery-strategy, is that ok to always recreate a client so that any > ephemeral node previously owned disappear? > The case I struggle with is the following: > Let's say I've acquired a lock (i.e. an ephemeral locknode is created). > Some application logic failed due to a connection loss. At this stage I'd > like to give up/roll back. Here I would typically throw an exception, the > lock being released in a finally. But I can't release the lock since the > connection is down. Later the client eventually reconnects, the session > didn't expire so the locknode still exists. Now no one else can acquire this > lock until my session expires. > > #3. could you describe the recommended actions for each exception code? > > I hope my questions would make some sense to you. Thanks in advance for > your answers, > > Alexis > > > > --001636b14763ad81910489cc76d6--