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 696C86297 for ; Mon, 16 May 2011 08:04:39 +0000 (UTC) Received: (qmail 70584 invoked by uid 500); 16 May 2011 08:04:38 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 70495 invoked by uid 500); 16 May 2011 08:04:37 -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 70428 invoked by uid 99); 16 May 2011 08:04:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 May 2011 08:04:37 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [81.255.196.200] (HELO lxmail2.goto.fr) (81.255.196.200) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 May 2011 08:04:30 +0000 Received: from Exchange.exchange2010.local (exchange.exchange2010.local [10.10.10.211]) by lxmail2.goto.fr (Postfix) with ESMTP id 0D70462502 for ; Mon, 16 May 2011 10:04:09 +0200 (CEST) Received: from [192.168.10.118] (192.168.10.118) by Exchange.exchange2010.local (10.10.10.211) with Microsoft SMTP Server (TLS) id 14.0.702.0; Mon, 16 May 2011 10:04:09 +0200 Subject: Re: Question about client connection From: Jeremy Sevellec To: In-Reply-To: References: <1305303050.3835.24.camel@jsevellec> Content-Type: multipart/alternative; boundary="=-Vy3u40gcLUTzMNvHzldP" Date: Mon, 16 May 2011 10:03:06 +0200 Message-ID: <1305532986.3835.26.camel@jsevellec> MIME-Version: 1.0 X-Mailer: Evolution 2.30.3 X-Virus-Checked: Checked by ClamAV on apache.org --=-Vy3u40gcLUTzMNvHzldP Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit I Think it's exactly what i need. I'm going to try this solution. thanks! Le samedi 14 mai 2011 à 20:40 +0800, 邢迪侃 a écrit : > This way: > > class Notifiery > { > public synchronized void Notify() > { > mNotified = true; > notify(); > } > public synchronized bool Wait(long timeout) > { > if (mNotified) return true; > wait(timeout); > return mNotified; > } > bool mNotified; > } > > Notifier n = new Notifier; > zk = new Zookeeper(.....); /// pass "n" to the init watch > bool connected = 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 = 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érémy > > --=-Vy3u40gcLUTzMNvHzldP--