adoroszlai commented on code in PR #10612:
URL: https://github.com/apache/ozone/pull/10612#discussion_r3482229032


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMNodeInfo.java:
##########
@@ -228,18 +229,22 @@ public String getNodeId() {
   }
 
   public String getBlockClientAddress() {
-    return blockClientAddress;
+    return blockClientAddress.getHostAndPortString();
   }
 
   public String getScmClientAddress() {
-    return scmClientAddress;
+    return scmClientAddress.getHostAndPortString();

Review Comment:
   For comments along the same line, it is better to suggest one change and 
mention that the suggestion applies to other parts of the code.  This makes the 
review less verbose, plus others do not need to respond to each similar comment.



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/net/HostAndPort.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdds.scm.net;
+
+import java.net.InetSocketAddress;
+import org.apache.hadoop.net.NetUtils;
+
+/**
+ * A class for host and port.
+ * It also has an address which can be updated from time to time.
+ */
+public class HostAndPort {

Review Comment:
   We can replace Guava's `HostAndPort` with this.  (Can be done in follow-up 
if considered out-of-scope.)



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMNodeInfo.java:
##########
@@ -228,18 +229,22 @@ public String getNodeId() {
   }
 
   public String getBlockClientAddress() {
-    return blockClientAddress;
+    return blockClientAddress.getHostAndPortString();

Review Comment:
   These `HostAndPort` variables in `SCMNodeInfo` are never `null`.  Let's add 
`Objects.requireNonNull` in the constructor instead.



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/net/HostAndPort.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdds.scm.net;
+
+import java.net.InetSocketAddress;
+import org.apache.hadoop.net.NetUtils;
+
+/**
+ * A class for host and port.
+ * It also has an address which can be updated from time to time.
+ */
+public class HostAndPort {
+  private final String host;
+  private final int port;
+  private final String hostAndPortString;
+  private final int hash;
+  /** The address can be updated from time to time. */
+  private InetSocketAddress address;
+
+  private HostAndPort(String host, int port, InetSocketAddress address) {
+    this.host = host;
+    this.port = port;
+    this.hostAndPortString = host + ":" + port;
+    this.hash = host.hashCode() ^ Integer.hashCode(port);
+    this.address = address != null ? address : 
NetUtils.createSocketAddr(hostAndPortString);

Review Comment:
   Use `InetSocketAddress.createUnresolved(host, port)` directly instead of 
Hadoop's `NetUtils.createSocketAddr`.  The latter parses the string, into host 
and port (so we can save this processing), and handles more complex cases that 
we do not need here.



-- 
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]

Reply via email to