swagle commented on a change in pull request #727: HDDS-3273. getConf does not
return all OM addresses.
URL: https://github.com/apache/hadoop-ozone/pull/727#discussion_r399053289
##########
File path:
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
##########
@@ -89,6 +93,31 @@ public static InetSocketAddress getOmAddress(Configuration
conf) {
return NetUtils.createSocketAddr(getOmRpcAddress(conf));
}
+ /**
+ * Return list of OM addresses by service ids - when HA is enabled.
+ *
+ * @param conf {@link Configuration}
+ * @return {service.id -> [{@link InetSocketAddress}]}
+ */
+ public static Map<String, List<InetSocketAddress>> getOmHAAddressesById(
+ Configuration conf) {
+ Map<String, List<InetSocketAddress>> result = new HashMap<>();
+ for (String serviceId : conf.getTrimmedStringCollection(
+ OZONE_OM_SERVICE_IDS_KEY)) {
+ if (!result.containsKey(serviceId)) {
+ result.put(serviceId, new ArrayList<>());
+ }
+ for (String nodeId : getOMNodeIds(conf, serviceId)) {
+ String rpcAddr = getOmRpcAddress(conf,
+ addKeySuffixes(OZONE_OM_ADDRESS_KEY, serviceId, nodeId));
+ if (rpcAddr != null) {
Review comment:
Thanks, Bharat for review.
Actually I modeled the method based on getOmAddress() and return
InetSocketAddress so cannot put random string in the map, I added a log message
instead.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]