You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2021/03/23 00:03:01 UTC

[GitHub] [zookeeper] aihuaxu commented on a change in pull request #1643: ZOOKEEPER-4250: Resolve zookeeper quorum from DNS entry.

aihuaxu commented on a change in pull request #1643:
URL: https://github.com/apache/zookeeper/pull/1643#discussion_r599154190



##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java
##########
@@ -655,6 +676,39 @@ public ZooKeeper(
         cnxn.start();
     }
 
+    /**
+     * Resolve configured zookeeper quorum DNS into the quorum string if necessary.
+     * Otherwise, the original quorum is returned.
+     *
+     * @param zkHostPort    zookeeper quorum string or DNS string
+     * @return The zookeeper quorum string
+     * @throws IOException If there are issues resolving the addresses.
+     */
+    private String resolveQuorumIfNecessary(String zkHostPort)
+            throws UnknownHostException {
+        if (zkHostPort == null || !this.resolveQuorumNeeded) {
+            // Early return is no resolve is necessary
+            return zkHostPort;
+        }
+
+        // decide whether to access server by IP or by host name
+        // If the address needs to be resolved, get all of the IP addresses
+        // from this address and pass them into the proxy
+        LOG.info(String.format("Zookeeper quorum will be resolved with %s",
+                resolver.getClass().getName()));
+
+        List<String> resolvedHosts = new ArrayList<>();
+        ConnectStringParser parser = new ConnectStringParser(zkHostPort);
+        for (InetSocketAddress address : parser.getServerAddresses()) {

Review comment:
       Actually it won't be null since it's always initialized in ConnectStringParser. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org