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


##########
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:
   ```suggestion
       return blockClientAddress == null ? null : 
blockClientAddress.getHostAndPortString();
   ```
   
   



##########
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:
   ```suggestion
       return scmClientAddress == null ? null : 
scmClientAddress.getHostAndPortString();
   ```



##########
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();
   }
 
   public String getScmSecurityAddress() {
-    return scmSecurityAddress;
+    return scmSecurityAddress.getHostAndPortString();
   }
 
-  public String getScmDatanodeAddress() {
+  public HostAndPort getScmDatanodeHostPortAddress() {
     return scmDatanodeAddress;
   }
+
+  public String getScmDatanodeAddress() {
+    return scmDatanodeAddress.getHostAndPortString();

Review Comment:
   ```suggestion
       return scmDatanodeAddress == null ? null : 
scmDatanodeAddress.getHostAndPortString();
   ```



##########
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();
   }
 
   public String getScmSecurityAddress() {
-    return scmSecurityAddress;
+    return scmSecurityAddress.getHostAndPortString();

Review Comment:
   ```suggestion
       return scmSecurityAddress == null ? null : 
scmSecurityAddress.getHostAndPortString();
   ```



##########
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);
+  }
+
+  public HostAndPort(String host, int port) {
+    this(host, port, null);
+  }
+
+  public HostAndPort(InetSocketAddress address) {
+    this(address.getHostName(), address.getPort(), address);
+  }
+
+  public String getHostName() {
+    return host;
+  }
+
+  public int getPort() {
+    return port;
+  }
+
+  public String getHostAndPortString() {
+    return hostAndPortString;
+  }
+
+  public synchronized InetSocketAddress getAddress() {

Review Comment:
   why is this synchronized?



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