avijayanhwx commented on a change in pull request #1243:
URL: https://github.com/apache/hadoop-ozone/pull/1243#discussion_r459622263
##########
File path:
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
##########
@@ -527,4 +529,45 @@ public static void validateKeyName(String keyName)
OMException.ResultCodes.INVALID_KEY_NAME);
}
}
+
+ /**
+ * Return configured OzoneManager service id based on the following logic.
+ * Look at 'ozone.om.internal.service.id' first. If configured, return that.
+ * If the above is not configured, look at 'ozone.om.service.ids'.
+ * If count(ozone.om.service.ids) == 1, return that id.
+ * If count(ozone.om.service.ids) > 1 throw exception
+ * If 'ozone.om.service.ids' is not configured, return null. (Non HA)
+ * @param conf configuration
+ * @return OM service ID.
+ * @throws IOException on error.
+ */
+ public static String getOzoneManagerServiceId(OzoneConfiguration conf)
+ throws IOException {
+ Collection<String> omServiceIds;
+ String localOMServiceId = conf.get(OZONE_OM_INTERNAL_SERVICE_ID);
+ if (localOMServiceId == null) {
+ LOG.info("{} is not defined, falling back to {} to find serviceID for "
+ + "OzoneManager if it is HA enabled cluster",
+ OZONE_OM_INTERNAL_SERVICE_ID, OZONE_OM_SERVICE_IDS_KEY);
+ omServiceIds = conf.getTrimmedStringCollection(
+ OZONE_OM_SERVICE_IDS_KEY);
+ if (omServiceIds.size() > 1) {
+ throw new IOException(String.format(
+ "More than 1 OzoneManager ServiceID (ozone.om.service.ids) " +
+ "configured : %s, but ozone.om.internal.service.id is not " +
+ "configured.", omServiceIds.toString()));
+ }
+ } else {
+ omServiceIds = Collections.singletonList(localOMServiceId);
+ }
+
Review comment:
Thanks @bharatviswa504. Will fix this.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]