tibrewalpratik17 commented on code in PR #12353: URL: https://github.com/apache/pinot/pull/12353#discussion_r1482663033
########## pinot-common/src/main/java/org/apache/pinot/common/utils/RoundRobinURIProvider.java: ########## @@ -63,4 +78,33 @@ public URI next() { _index = (_index + 1) % _uris.length; return result; } + + public URI[] resolveHostToIPAddresses(URI originalUri) + throws UnknownHostException, URISyntaxException { + URI[] resolvedUris; + String hostName = originalUri.getHost(); + if (InetAddresses.isInetAddress(hostName)) { + resolvedUris = new URI[]{originalUri}; + } else { + // Resolve host name to IP addresses via DNS + InetAddress[] addresses = InetAddress.getAllByName(hostName); + resolvedUris = new URI[addresses.length]; + URIBuilder uriBuilder = new URIBuilder(originalUri); + for (int i = 0; i < addresses.length; i++) { + String ip = addresses[i].getHostAddress(); + resolvedUris[i] = uriBuilder.setHost(ip).build(); + } + } + return resolvedUris; + } + + public URI[] resolveHostsToIPAddresses(List<URI> originalUri) + throws UnknownHostException, URISyntaxException { + List<URI> resolvedUrisList = new ArrayList<>(); + for (URI uri : originalUri) { + resolvedUrisList.addAll(List.of(resolveHostToIPAddresses(uri))); + } + + return resolvedUrisList.toArray(new URI[0]); Review Comment: Done -- 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. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org