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 A21676224 for ; Sat, 28 May 2011 19:18:11 +0000 (UTC) Received: (qmail 33078 invoked by uid 500); 28 May 2011 19:18:11 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 33036 invoked by uid 500); 28 May 2011 19:18:10 -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 32984 invoked by uid 500); 28 May 2011 19:18:10 -0000 Delivered-To: apmail-hadoop-zookeeper-user@hadoop.apache.org Received: (qmail 32944 invoked by uid 99); 28 May 2011 19:18:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 May 2011 19:18:10 +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 (athena.apache.org: domain of ted.dunning@gmail.com designates 209.85.220.176 as permitted sender) Received: from [209.85.220.176] (HELO mail-vx0-f176.google.com) (209.85.220.176) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 28 May 2011 19:18:04 +0000 Received: by vxa37 with SMTP id 37so3156736vxa.35 for ; Sat, 28 May 2011 12:17:43 -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:from:date :message-id:subject:to:cc:content-type; bh=tlYpZ3f7y47ylpCx2bOlXatALzUpegELRHDU4vAMYEU=; b=x/2cVrfwfo8MGXiJmClYFg251gYPHkyCPSsXv5olJqmuk+hz5I17vZgy72og1Kz+jC 3J2BAwV3utQmjfVtKTPrmzeqFF5CKJRGa8hgMC0ehd0sPUEzC1EUn9KldHlE2ui+CPDL 6RvE9AdJcBeNhCx/RrmBeamt4JbFYQY0WgIsA= 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 :cc:content-type; b=QRl7V0d69+4mNCz5nATyEJftUumG4enqR5C0YV7Ywr1bkIyY4nKdmg3DrNw73E0sMs EBl0XVFCD1lYo/I1ShVaAUD7pMcYef3KThvpzJuH67vHkfb/8DjxZj5qErjA+PJQ/+YW /dPTJRoQFJrgFALjcrjmlwGR7OQ3gS2qZ8ODc= Received: by 10.52.18.14 with SMTP id s14mr3540545vdd.164.1306610263079; Sat, 28 May 2011 12:17:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.110.101 with HTTP; Sat, 28 May 2011 12:17:23 -0700 (PDT) In-Reply-To: References: From: Ted Dunning Date: Sat, 28 May 2011 12:17:23 -0700 Message-ID: Subject: Re: Zookeeper in embedded mode To: user@zookeeper.apache.org Cc: zookeeper-user Content-Type: multipart/alternative; boundary=20cf3054a12f973d4f04a45ae896 --20cf3054a12f973d4f04a45ae896 Content-Type: text/plain; charset=UTF-8 There is a bit of a conundrum here. Your problem is one of coordination. In the Zookeeper world, it is common to solve problems like this using ephemeral znodes to indicate that a server is up. Your problem is that you are trying to coordinate with the Zookeeper process itself and don't have an external Zookeeper available to help you. This problem of coordinating with the coordinator is exactly what makes embedded use of Zookeeper somewhat problematic. I have written, used and tried to maintain applications that have embedded Zookeepers and this has always been a problem. In addition, using an embedded Zookeeper also leads to multi-master issues because it is usually possible to invoke multiple copies of the program with the embedded Zookeeper. You don't usually want to hunt for a port number because the ZK port should be a well-known thing (test cases are the major exception) and you don't usually want to share some other invocations embedded Zookeeper. You also don't usually want Zookeeper to go down just because of an application error. All in all, I really prefer to have a separate Zookeeper service and avoid embedded designs. There is a small management overhead (just start it once and arrange for restart on reboot ... it will run forever). On Sat, May 28, 2011 at 10:18 AM, Avinash Lakshman < avinash.lakshman@gmail.com> wrote: > Hi All > > I am trying to run ZK in embedded mode. Basically I invoke > QuorumPeerMain.main() on a separate thread. However is there a way to > programmatically determine if the local server is ready to take write > requests? I would like to on a separate thread create a Zookeeper instance > and save some state. Currently I have a Thread.sleep(10seconds) to achieve > what I want. > > Thanks in advance > Avinash > --20cf3054a12f973d4f04a45ae896--