sadanand48 commented on code in PR #4325:
URL: https://github.com/apache/ozone/pull/4325#discussion_r1134570744
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java:
##########
@@ -790,4 +791,30 @@ public static String format(List<ServiceInfo> nodes, int
port,
return sb.toString();
}
}
+
+ /**
+ * @param omHost
+ * @param omPort
+ * If the authority in the URI is not one of the service ID's,
+ * it is treated as a hostname. Check if this hostname can be resolved
+ * and if it's reachable.
+ */
+ public static void resolveOmHost(String omHost, int omPort)
+ throws IOException {
+ InetSocketAddress omHostAddress = NetUtils.createSocketAddr(omHost,
omPort);
+ if (omHostAddress.isUnresolved()) {
+ throw new IllegalArgumentException(
+ "Cannot resolve OM host " + omHost + " in the URI",
+ new UnknownHostException());
+ }
+ try {
+ if (!omHostAddress.getAddress().isReachable(5000)) {
+ throw new IllegalArgumentException(
+ "OM host " + omHost + " unreachable in the URI");
+ }
+ } catch (IOException e) {
+ LOG.error("Failure in resolving OM host address", e);
+ throw e;
+ }
+ }
Review Comment:
Done, tried it and it works.
```bash
bash-4.2$ ozone fs -ls ofs://om/
Found 1 items
drwxrwxrwx - hadoop hadoop 0 2023-03-13 20:13 ofs://om/s3v
bash-4.2$ ozone fs -ls ofs://om1/
ls: Cannot resolve OM host om1 in the URI
bash-4.2$ exit
--
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]