Github user arshadmohammad commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/153#discussion_r97257715
--- Diff: src/java/test/org/apache/zookeeper/test/ClientBase.java ---
@@ -664,4 +664,32 @@ public static String join(String separator, Object[]
parts) {
}
return sb.toString();
}
+
+ public static ZooKeeper createZKClient(String cxnString) throws
Exception {
+ return createZKClient(cxnString, CONNECTION_TIMEOUT);
+ }
+
+ /**
+ * Returns ZooKeeper client after connecting to ZooKeeper Server.
Session
+ * timeout is {@link #CONNECTION_TIMEOUT}
+ *
+ * @param cxnString
+ * connection string in the form of host:port
+ * @param sessionTimeout
+ * @throws IOException
+ * in cases of network failure
+ */
+ public static ZooKeeper createZKClient(String cxnString, int
sessionTimeout) throws IOException {
+ CountdownWatcher watcher = new CountdownWatcher();
+ ZooKeeper zk = new ZooKeeper(cxnString, sessionTimeout, watcher);
+ try {
+ watcher.waitForConnected(CONNECTION_TIMEOUT);
+ } catch (InterruptedException e) {
+ Assert.fail("ZooKeeper client can not connect to " +
cxnString);
+ }
+ catch (TimeoutException e) {
+ Assert.fail("ZooKeeper client can not connect to " +
cxnString);
+ }
+ return zk;
+ }
}
--- End diff --
Thanks Rakesh.
Changes LGTM, +1
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---