Return-Path: Delivered-To: apmail-hadoop-zookeeper-user-archive@minotaur.apache.org Received: (qmail 80974 invoked from network); 28 Apr 2010 04:52:02 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 Apr 2010 04:52:02 -0000 Received: (qmail 16774 invoked by uid 500); 28 Apr 2010 04:52:02 -0000 Delivered-To: apmail-hadoop-zookeeper-user-archive@hadoop.apache.org Received: (qmail 16710 invoked by uid 500); 28 Apr 2010 04:52:01 -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 16702 invoked by uid 99); 28 Apr 2010 04:52:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Apr 2010 04:52:01 +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 lzvoyager@gmail.com designates 209.85.221.193 as permitted sender) Received: from [209.85.221.193] (HELO mail-qy0-f193.google.com) (209.85.221.193) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Apr 2010 04:51:53 +0000 Received: by qyk31 with SMTP id 31so20013721qyk.20 for ; Tue, 27 Apr 2010 21:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=Lij8lHD7wPytUYFL8wNFb9cum+lJz8QonJHXqUJXF3E=; b=xokXvq9+/mSpbECfXTUsFZItwKkEHmIBB9whOtkpR0f3mYVsuqthyUk7YXj2lSmp2Q 0jQeGoAu+OtHM4T9KCqJEGWhIos8kLDlNSmIVTFf3s1TN2wWoEeUdK9UbnC3Hi1Jt8RY 0L7Zdru0U5aD9Tq+xoqKTqWfTquRcXzuf8Hiw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=B6rrTcuS2x1Toj/CnCMpVvJQi48mO0T5XsXRVY5hZc3VCPbiNeQ0r3+TZesoeK44kF x6jEWuPNPA5cSd/JCYirH8Khw6wyB/fGxpEcR2ru7SVZq+FGUiTQX8YYbYS9DzVfkX2m jx5QtD3B8/EHvnns6AneGPnsFMlDInmGv0hNo= MIME-Version: 1.0 Received: by 10.224.35.216 with SMTP id q24mr2096195qad.79.1272430292144; Tue, 27 Apr 2010 21:51:32 -0700 (PDT) Received: by 10.224.54.136 with HTTP; Tue, 27 Apr 2010 21:51:32 -0700 (PDT) In-Reply-To: References: <4BD77075.7070603@apache.org> Date: Tue, 27 Apr 2010 21:51:32 -0700 Message-ID: Subject: Re: Bizarre ZooKeeper Client Behaviour From: Lei Zhang To: zookeeper-user@hadoop.apache.org Content-Type: multipart/alternative; boundary=00c09f9c9c35909493048544c365 X-Virus-Checked: Checked by ClamAV on apache.org --00c09f9c9c35909493048544c365 Content-Type: text/plain; charset=ISO-8859-1 Ted - You can think of this as a problem with using singleton in a multi-threaded program. The solution that provides better code readability at affordable cost should win. Specifically the problem I am trying to solve is this: We have a multi-threaded webapp based on a framework (means I am not yet able to find out how the framework spawns threads, cleaning up the threads). Each thread has local states that must be cleaned up on zookeeper fatal error; and the desired zookeeper error recovery is to reopen the session. The choices on the table are: 1. 1 zk session for the whole webapp 2. 1 zk session for each thread Option 1 proves to be tricky to implement - since more than 1 threads can catch zk fatal error, I would have to implement proper synchronization mechanism to prevent same session being closed/reopened rapidly back to back; besides, I need to implement a way to request the threads that did not catch zk fatal error to clean up their local states. Option 2 I haven't prototyped out completely. It is likely the webapp may become laden with zk threads. I suspect we'll run into zk threads race condition. I'd like to hear from people who actually struggled with similar design decision. Lei On Tue, Apr 27, 2010 at 7:12 PM, Ted Dunning wrote: > Lei, > > A contrary question for you is why you don't just share zk sessions within > a > single process. > > --00c09f9c9c35909493048544c365--