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 27DEC18A6A for ; Fri, 24 Jul 2015 23:28:17 +0000 (UTC) Received: (qmail 32303 invoked by uid 500); 24 Jul 2015 23:28:16 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 32244 invoked by uid 500); 24 Jul 2015 23:28:16 -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 32233 invoked by uid 99); 24 Jul 2015 23:28:16 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Jul 2015 23:28:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 9731ED76D7 for ; Fri, 24 Jul 2015 23:28:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=6.31 tests=[SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Zw5185fPamWi for ; Fri, 24 Jul 2015 23:28:07 +0000 (UTC) Received: from relayvx11a.securemail.intermedia.net (relayvx11a.securemail.intermedia.net [64.78.56.46]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id BF42843CC9 for ; Fri, 24 Jul 2015 23:28:06 +0000 (UTC) Received: from securemail.intermedia.net (localhost [127.0.0.1]) by emg-ca-1-1.localdomain (Postfix) with ESMTP id 4FFB953E8B for ; Fri, 24 Jul 2015 16:27:39 -0700 (PDT) Subject: Re: ZooKeeper Class Will Not Connect MIME-Version: 1.0 x-echoworx-emg-received: Fri, 24 Jul 2015 16:27:39.288 -0700 x-echoworx-msg-id: 34249c1f-2022-477c-a64b-57f62c225656 x-echoworx-action: delivered Received: from emg-ca-1-1.securemail.intermedia.net ([10.254.155.11]) by emg-ca-1-1 (JAMES SMTP Server 2.3.2) with SMTP ID 503 for ; Fri, 24 Jul 2015 16:27:39 -0700 (PDT) Received: from MBX080-W4-CO-2.exch080.serverpod.net (unknown [10.224.117.102]) by emg-ca-1-1.localdomain (Postfix) with ESMTP id 179B353E8B for ; Fri, 24 Jul 2015 16:27:39 -0700 (PDT) Received: from MBX080-W4-CO-2.exch080.serverpod.net (10.224.117.102) by MBX080-W4-CO-2.exch080.serverpod.net (10.224.117.102) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Fri, 24 Jul 2015 16:27:38 -0700 Received: from MBX080-W4-CO-2.exch080.serverpod.net ([10.224.117.102]) by mbx080-w4-co-2.exch080.serverpod.net ([10.224.117.102]) with mapi id 15.00.1044.021; Fri, 24 Jul 2015 16:27:38 -0700 From: Chris Nauroth To: "user@zookeeper.apache.org" Thread-Topic: ZooKeeper Class Will Not Connect Thread-Index: AQHQxW476JmVCghwKk6ADVlL1CkPxp3qTAuAgAD2ioD//+/9AIAAfAEA//+XNQA= Date: Fri, 24 Jul 2015 23:27:37 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [50.248.208.113] x-source-routing-agent: Processed Content-Type: text/plain; charset="us-ascii" Content-ID: <8BDA956792709F4D8054E72E09F97B66@exch080.serverpod.net> Content-Transfer-Encoding: quoted-printable ZooKeeper writes INFO-level logging about connection and session establishment. On the client side, these messages would come from the ZooKeeper and ClientCnxn classes. On the server side, these messages would come from the ZooKeeperServer, NIOServerCnxn and NettyServerCnxn classes. It's possible that you could get more detail by turning up to DEBUG level logging by adding these lines to log4j.properties for the client and server respectively: log4j.logger.org.apache.zookeeper=3DDEBUG log4j.logger.org.apache.zookeeper.server=3DDEBUG --Chris Nauroth On 7/24/15, 3:42 PM, "Chris Barlock" wrote: >Chris: > >I have defined: > > private static final int MAX_ZK_CONNECT_ATTEMPTS =3D 400; >=20 > private static final long ZK_CONNECT_WAIT =3D 5; // Milliseconds > >so, two seconds, but I have also tried with ZK_CONNECT_WAIT =3D 500 (two >hundred seconds). getState always returned CONNECTING. I can play with >the async notification, but it really doesn't fit my application very >well. Is there any additional server or client tracing that can be >enabled to get a better sense of what is going on? > >Chris > >IBM Tivoli Systems >Research Triangle Park, NC >(919) 224-2240 >Internet: barlock@us.ibm.com > > > >From: Chris Nauroth >To: "user@zookeeper.apache.org" >Date: 07/24/2015 06:19 PM >Subject: Re: ZooKeeper Class Will Not Connect > > > >Hello Chris, > >Thank you for the detailed repro steps describing which versions work and >which versions don't work. I tested your code sample against a 3.4.6 >build, and it worked consistently for me. My only thought is that perhaps >the MAX_ZK_CONNECT_ATTEMPTS and ZK_CONNECT_WAIT constants are set such >that the polling loop exits before the connection completes. Perhaps a >subtle timing difference in the newer versions is just now exposing this. > >The typical pattern for connection establishment is to rely on the >ZooKeeper client's asynchronous event notification instead of a polling >loop. See below for a code sample that initiates the connection and then >waits for the SyncConnected event. The ZooKeeper programmer's guide and >example program docs have a more detailed discussion of this. > >http://zookeeper.apache.org/doc/r3.4.6/zookeeperProgrammers.html > > >http://zookeeper.apache.org/doc/r3.4.6/javaExample.html > > >Could you please try running this against your 3.4.6 cluster? I'd be >curious to see if the connection completes for you. This would also give >you a sense for how long connection establishment is taking and whether or >not that's in line with your definitions of MAX_ZK_CONNECT_ATTEMPTS and >ZK_CONNECT_WAIT. > >I hope this helps. > > > >class Main implements Watcher { > > private final CountDownLatch connectLatch; > private final ZooKeeper zk; > > public static void main(final String[] args) throws Exception { > String hostPort =3D args[0]; > Main main =3D new Main(hostPort); > main.awaitConnection(); > System.out.println("Exiting."); > } > > private Main(String hostPort) throws Exception { > this.connectLatch =3D new CountDownLatch(1); > this.zk =3D new ZooKeeper(hostPort, 3000, this); > } > > private void awaitConnection() throws InterruptedException { > this.connectLatch.await(); > System.out.println("Connection has completed."); > } > > @Override > public void process(WatchedEvent event) { > System.out.println("Received event: " + event); > if (event.getType() =3D=3D Event.EventType.None) { > switch (event.getState()) { > case SyncConnected: > this.connectLatch.countDown(); > break; > } > } > } >} > > >--Chris Nauroth > > > > >On 7/24/15, 9:16 AM, "Chris Barlock" wrote: > >>Ran some more tests. My code works fine up through ZK 3.4.2, but then >>fails with 3.4.3. I did have to add the following to the Import-Package >>list in the ZK MANIFEST.MF: >> >>org.slf4 j,javax.security.auth.login,javax.security.sasl >> >>I could really use some help here, ZK folks! Is my code incorrect with >>newer versions of ZK, or is ZK broken? >> >>Chris >> >> >> >> >> >>From: Chris Barlock/Raleigh/IBM@IBMUS >>To: user@zookeeper.apache.org >>Date: 07/23/2015 09:34 PM >>Subject: Re: ZooKeeper Class Will Not Connect >> >> >> >>I tried the 3.5.0 alpha build to see if it made any difference. It did >>not. >> >>But, I had to hack the MANIFEST.MF file in the JAR because the >>"3.50-alpha" version fails tests in OSGi bundles that import the ZK >>classes which have something like: >> >>version=3D"[3.2,4)" >> >>I suggest that if you want to name the JAR "3.50-alpha" that all the >>internals just use a version of 3.50. >> >>Chris >> >>IBM Tivoli Systems >>Research Triangle Park, NC >>(919) 224-2240 >>Internet: barlock@us.ibm.com >> >> >> >>From: Chris Barlock/Raleigh/IBM@IBMUS >>To: user@zookeeper.apache.org >>Date: 07/23/2015 01:37 PM >>Subject: ZooKeeper Class Will Not Connect >> >> >> >>We are attempting to upgrade from Kafka 0.8.0, which includes ZK 3.3.4 to >>Kafka 0.8.2.1 with ZK 3.4.6. My code which attempts to connect to ZK is >>pretty straightforward: >> >> try { >> ZooKeeper zk =3D new ZooKeeper(connectString, >sessionTimeout >>, this); >> int connectAttempts =3D 0; >> >> while (!zk.getState().isConnected() && connectAttempts < >>MAX_ZK_CONNECT_ATTEMPTS) { >> try { >> Thread.sleep(ZK_CONNECT_WAIT); >> } catch (InterruptedException e) { >> // Ignore >> } >> connectAttempts++; >> } >> } catch (IOException e) { >> trace.exception(CLASS_NAME, methodName, e); >> } >> >>With some additional tracing, States is always CONNECTING. Has something >>changed with 3.4.6 about how I should connect to the server? I can >>connect just fine with the zookeeper-shell.sh that Kafka ships. This >>code=20 >> >> >>always runs on the same system as ZK, so the connectString is always >>"localhost:2181" >> >>Chris >> > >