RexXiong commented on code in PR #2489:
URL: https://github.com/apache/celeborn/pull/2489#discussion_r1591730278


##########
common/src/main/scala/org/apache/celeborn/common/util/Utils.scala:
##########
@@ -432,6 +432,29 @@ object Utils extends Logging {
     }
   }
 
+  private def getIpHostAddressPair(host: String): (String, String) = {
+    try {
+      val inetAddress = InetAddress.getByName(host)
+      val hostAddress = inetAddress.getHostAddress
+      if (host.equals(hostAddress)) {
+        (hostAddress, inetAddress.getCanonicalHostName)
+      } else {
+        (hostAddress, host)
+      }
+    } catch {
+      case _: Throwable => (host, host) // return original input
+    }
+  }
+
+  // Convert address (ip:port or host:port) to (ip:port, host:port) pair
+  def addressToIpHostAddressPair(address: String): (String, String) = {
+    val hostPort = Utils.parseHostPort(address)
+    val internalIpHostAddressPair = Utils.getIpHostAddressPair(hostPort._1)
+    (
+      internalIpHostAddressPair._1 + ":" + hostPort._2,
+      internalIpHostAddressPair._2 + ":" + hostPort._2)

Review Comment:
   Thanks, done.



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

Reply via email to