sokui commented on code in PR #3186:
URL: https://github.com/apache/ozone/pull/3186#discussion_r902962019


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java:
##########
@@ -362,33 +362,33 @@ public RegisteredCommand register(
           .build();
     }
 
+    InetAddress dnAddress = Server.getRemoteIp();
+    if (dnAddress != null) {
+      // Mostly called inside an RPC, update ip
+      datanodeDetails.setIpAddress(dnAddress.getHostAddress());
+    }
+
+    String dnsName;
+    String networkLocation;
+    datanodeDetails.setNetworkName(datanodeDetails.getUuidString());
+    if (useHostname) {
+      dnsName = datanodeDetails.getHostName();
+    } else {
+      dnsName = datanodeDetails.getIpAddress();
+    }
+    networkLocation = nodeResolve(dnsName);
+    if (networkLocation != null) {
+      datanodeDetails.setNetworkLocation(networkLocation);
+    }
+
     if (!isNodeRegistered(datanodeDetails)) {
-      InetAddress dnAddress = Server.getRemoteIp();
-      if (dnAddress != null) {
-        // Mostly called inside an RPC, update ip and peer hostname
-        datanodeDetails.setHostName(dnAddress.getHostName());

Review Comment:
   What I was saying is that even we delete this line 
`datanodeDetails.setHostName(dnAddress.getHostName());`, it should be still 
fine because when datanode register with scm, the datanodeDetails already have 
the hostName info. But to be conservative, I just use the above logic to make 
sure when `DFS_DATANODE_USE_DN_HOSTNAME` is not enabled, the code is the 
exactly same as before.



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