hemanthboyina commented on code in PR #3290: URL: https://github.com/apache/hadoop/pull/3290#discussion_r850414027
########## hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java: ########## @@ -1218,4 +1219,31 @@ public static InetAddress bindToLocalAddress(InetAddress localAddr, boolean } return null; } + + /** + * Parse the given address into IP & Port number pair. + * @param bindAddress IP Address to parse + * @return Pair of IP-Address & Port number. + */ + public static Pair<String, Integer> parseAddress2IpAndPort( + String bindAddress) { + String[] parts = org.apache.hadoop.util.StringUtils + .split(bindAddress, ':'); + Pair <String, Integer> pair = null; + //If bind address is IPv6 + if (bindAddress.split(":").length > 2) { Review Comment: can use parts.length > 2, as parts is equal to bindAddress.split(":") ########## hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java: ########## @@ -1218,4 +1219,31 @@ public static InetAddress bindToLocalAddress(InetAddress localAddr, boolean } return null; } + + /** + * Parse the given address into IP & Port number pair. + * @param bindAddress IP Address to parse + * @return Pair of IP-Address & Port number. + */ + public static Pair<String, Integer> parseAddress2IpAndPort( + String bindAddress) { + String[] parts = org.apache.hadoop.util.StringUtils + .split(bindAddress, ':'); + Pair <String, Integer> pair = null; + //If bind address is IPv6 + if (bindAddress.split(":").length > 2) { + String target = bindAddress; + int i = target.lastIndexOf(":"); + String portNum = target.substring(i + 1); Review Comment: can use parts array itself to find out the port ? -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org