Return-Path: Delivered-To: apmail-hadoop-zookeeper-commits-archive@minotaur.apache.org Received: (qmail 98666 invoked from network); 7 Aug 2009 18:01:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Aug 2009 18:01:06 -0000 Received: (qmail 33169 invoked by uid 500); 7 Aug 2009 18:01:13 -0000 Delivered-To: apmail-hadoop-zookeeper-commits-archive@hadoop.apache.org Received: (qmail 33138 invoked by uid 500); 7 Aug 2009 18:01:13 -0000 Mailing-List: contact zookeeper-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: zookeeper-dev@ Delivered-To: mailing list zookeeper-commits@hadoop.apache.org Received: (qmail 33128 invoked by uid 99); 7 Aug 2009 18:01:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Aug 2009 18:01:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Aug 2009 18:01:09 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 75F3F23888AD; Fri, 7 Aug 2009 18:00:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r802108 - in /hadoop/zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/ZooKeeper.java Date: Fri, 07 Aug 2009 18:00:48 -0000 To: zookeeper-commits@hadoop.apache.org From: phunt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090807180048.75F3F23888AD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: phunt Date: Fri Aug 7 18:00:48 2009 New Revision: 802108 URL: http://svn.apache.org/viewvc?rev=802108&view=rev Log: ZOOKEEPER-490. the java docs for session creation are misleading/incomplete Modified: hadoop/zookeeper/trunk/CHANGES.txt hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java Modified: hadoop/zookeeper/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=802108&r1=802107&r2=802108&view=diff ============================================================================== --- hadoop/zookeeper/trunk/CHANGES.txt (original) +++ hadoop/zookeeper/trunk/CHANGES.txt Fri Aug 7 18:00:48 2009 @@ -46,11 +46,15 @@ ZOOKEEPER-493. patch for command line setquota (steve bendiola via phunt) - ZOOKEEPER-311. handle small path lengths in zoo_create() (chris barroch via breed) + ZOOKEEPER-311. handle small path lengths in zoo_create() + (chris barroch via breed) ZOOKEEPER-484. Clients get SESSION MOVED exception when switching from follower to a leader. (mahadev) + ZOOKEEPER-490. the java docs for session creation are misleading/incomplete + (phunt) + IMPROVEMENTS: ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to "socket reuse" and failure to close client (phunt via mahadev) Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java?rev=802108&r1=802107&r2=802108&view=diff ============================================================================== --- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java (original) +++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeper.java Fri Aug 7 18:00:48 2009 @@ -60,6 +60,7 @@ * This is the main class of ZooKeeper client library. To use a ZooKeeper * service, an application must first instantiate an object of ZooKeeper class. * All the iterations will be done by calling the methods of ZooKeeper class. + * The methods of this class are thread-safe unless otherwise noted. *

* Once a connection to a server is established, a session ID is assigned to the * client. The client will send heart beats to the server periodically to keep @@ -324,18 +325,28 @@ * connection string containing a comma separated list of host:port pairs, * each corresponding to a ZooKeeper server. *

- * The client object will pick an arbitrary server and try to connect to it. - * If failed, it will try the next one in the list, until a connection is - * established, or all the servers have been tried. + * Session establishment is asynchronous. This constructor will initiate + * connection to the server and return immediately - potentially (usually) + * before the session is fully established. The watcher argument specifies + * the watcher that will be notified of any changes in state. This + * notification can come at any point before or after the constructor call + * has returned. + *

+ * The instantiated ZooKeeper client object will pick an arbitrary server + * from the connectString and attempt to connect to it. If establishment of + * the connection fails, another server in the connect string will be tried + * (the order is non-deterministic, as we random shuffle the list), until a + * connection is established. The client will continue attempts until the + * session is explicitly closed. *

* Added in 3.2.0: An optional "chroot" suffix may also be appended to the * connection string. This will run the client commands while interpreting * all paths relative to this root (similar to the unix chroot command). - * + * * @param connectString * comma separated host:port pairs, each corresponding to a zk - * server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002" - * If the optional chroot suffix is used the example would look + * server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002" If + * the optional chroot suffix is used the example would look * like: "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002/app/a" * where the client would be rooted at "/app/a" and all paths * would be relative to this root - ie getting/setting/etc... @@ -346,9 +357,11 @@ * @param watcher * a watcher object which will be notified of state changes, may * also be notified for node events - * - * @throws IOException in cases of network failure - * @throws IllegalArgumentException if an invalid chroot path is specified + * + * @throws IOException + * in cases of network failure + * @throws IllegalArgumentException + * if an invalid chroot path is specified */ public ZooKeeper(String connectString, int sessionTimeout, Watcher watcher) throws IOException @@ -366,9 +379,19 @@ * connection string containing a comma separated list of host:port pairs, * each corresponding to a ZooKeeper server. *

- * The client object will pick an arbitrary server and try to connect to it. - * If failed, it will try the next one in the list, until a connection is - * established, or all the servers have been tried. + * Session establishment is asynchronous. This constructor will initiate + * connection to the server and return immediately - potentially (usually) + * before the session is fully established. The watcher argument specifies + * the watcher that will be notified of any changes in state. This + * notification can come at any point before or after the constructor call + * has returned. + *

+ * The instantiated ZooKeeper client object will pick an arbitrary server + * from the connectString and attempt to connect to it. If establishment of + * the connection fails, another server in the connect string will be tried + * (the order is non-deterministic, as we random shuffle the list), until a + * connection is established. The client will continue attempts until the + * session is explicitly closed (or the session is expired by the server). *

* Added in 3.2.0: An optional "chroot" suffix may also be appended to the * connection string. This will run the client commands while interpreting @@ -424,6 +447,8 @@ * not valid until the client connects to a server and may change after a * re-connect. * + * This method is NOT thread safe + * * @return current session id */ public long getSessionId() { @@ -435,16 +460,32 @@ * returned is not valid until the client connects to a server and may * change after a re-connect. * + * This method is NOT thread safe + * * @return current session password */ public byte[] getSessionPasswd() { return cnxn.getSessionPasswd(); } + /** + * Add the specified scheme:auth information to this connection. + * + * This method is NOT thread safe + * + * @param scheme + * @param auth + */ public void addAuthInfo(String scheme, byte auth[]) { cnxn.addAuthInfo(scheme, auth); } + /** + * Specify the default watcher for the connection (overrides the one + * specified during construction). + * + * @param watcher + */ public synchronized void register(Watcher watcher) { watchManager.defaultWatcher = watcher; }