Return-Path: X-Original-To: apmail-zookeeper-user-archive@www.apache.org Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4DFCA627B for ; Sat, 14 May 2011 12:40:49 +0000 (UTC) Received: (qmail 29339 invoked by uid 500); 14 May 2011 12:40:48 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 29298 invoked by uid 500); 14 May 2011 12:40:48 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 29289 invoked by uid 99); 14 May 2011 12:40:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 May 2011 12:40:48 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of xingdk.apex@gmail.com designates 209.85.216.42 as permitted sender) Received: from [209.85.216.42] (HELO mail-qw0-f42.google.com) (209.85.216.42) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 May 2011 12:40:41 +0000 Received: by qwi4 with SMTP id 4so2448687qwi.15 for ; Sat, 14 May 2011 05:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=lCKaVwdlDAPjCPctP/LgMaNW7WD++0qrji1y+Q9M40U=; b=JKsDwNNkmfocyURUW1RVmXOdYzaeCYk05iDtq2r6fnWUDbFQeLjXIxW2r5dWLg4ywx OklIkpDvnwCHxx7B7G8YC8QBrvCaMyrPCVQ9qWwD7zFT60aSYPuqX1L5bXdsqIKgRXm8 JtgtTjMd6NaF66xNmBqdkjl+lb4ywNtJn5KC4= 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=qBtFbxKxNKG449yPar0NoP78M8r/Qb91eorHQkBKeytZM1UW4udxEvP6R/JsGAAHDr e3n4jKDtVwptcmYwm8Ak9IqqvTUZcGqPq0z0yhbNvBRQEkn0W3gPpj+aRvm3YBDzvpEI CwdjchA9U3wZApXBdf+ZBnUU7IirI1KFWZwlA= MIME-Version: 1.0 Received: by 10.229.66.25 with SMTP id l25mr1911853qci.265.1305376819205; Sat, 14 May 2011 05:40:19 -0700 (PDT) Received: by 10.229.187.7 with HTTP; Sat, 14 May 2011 05:40:19 -0700 (PDT) In-Reply-To: <1305303050.3835.24.camel@jsevellec> References: <1305303050.3835.24.camel@jsevellec> Date: Sat, 14 May 2011 20:40:19 +0800 Message-ID: Subject: Re: Question about client connection From: =?GB2312?B?0M+1z9mp?= To: user@zookeeper.apache.org Content-Type: multipart/alternative; boundary=0016e64ea4549b57b704a33bb995 X-Virus-Checked: Checked by ClamAV on apache.org --0016e64ea4549b57b704a33bb995 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable This way: class Notifiery { public synchronized void Notify() { mNotified =3D true; notify(); } public synchronized bool Wait(long timeout) { if (mNotified) return true; wait(timeout); return mNotified; } bool mNotified; } Notifier n =3D new Notifier; zk =3D new Zookeeper(.....); /// pass "n" to the init watch bool connected =3D n.Wait(your_tolerant_timeout); if (!connected) { zk.close(); throw something; } Inside the init watch, n.Notify() after you see a CONNECTED event. 2011/5/14 Jeremy Sevellec > Hi Everyone, > > I'm new to Zookeeper and I'm trying to use it to make some distributed > lock. Globally, It works perfect! > > I've got a question about zookeeper client connection to a dead > zookeeper server . > > When I'm doing this connec to to a dead zookeeper server like this (the > code works fine when the server is up) : > zooKeeper =3D new ZooKeeper(....). > > The zookeeper client failed to connect but loop infinitely to try to > connect again and again. Is there any solution to know [catch] that it's > impossible to connect to a zookeeper server to be abble to make > something? > > Regards, > > J=E9r=E9my > --0016e64ea4549b57b704a33bb995--