xinglin commented on code in PR #6183:
URL: https://github.com/apache/hadoop/pull/6183#discussion_r1392918855
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java:
##########
@@ -1982,4 +1983,32 @@ public static void addTransferRateMetric(final
DataNodeMetrics metrics, final lo
LOG.warn("Unexpected value for data transfer bytes={} duration={}",
read, duration);
}
}
+
+ /**
+ * Construct a HostSet from an array of "ip:port" strings.
+ * @param nodesHostPort ip port string array.
+ * @return HostSet of InetSocketAddress.
+ */
+ public static HostSet getHostSet(String[] nodesHostPort) {
+ HostSet retSet = new HostSet();
+ for (String hostPort : nodesHostPort) {
+ try {
+ URI uri = new URI("dummy", hostPort, null, null, null);
+ int port = uri.getPort();
+ if (port == -1 || port == 0) {
Review Comment:
port=0 is valid. I guess we should probably just check for -1 here?
```
/**
* Returns the port number of this URI.
*
* <p> The port component of a URI, if defined, is a non-negative
* integer. </p>
*
* @return The port component of this URI,
* or {@code -1} if the port is undefined
*/
public int getPort() {
return 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]