arp7 commented on a change in pull request #703: HDDS-1371. Download RocksDB checkpoint from OM Leader to Follower. URL: https://github.com/apache/hadoop/pull/703#discussion_r273735098
########## File path: hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java ########## @@ -361,4 +373,149 @@ private static void addFilesToArchive(String source, File file, } } + /** + * If a OM conf is only set with key suffixed with OM Node ID, return the + * set value. + * @return null if base conf key is set, otherwise the value set for + * key suffixed with Node ID. + */ + public static String getConfSuffixedWithOMNodeId(Configuration conf, + String confKey, String omNodeId) { + String confValue = conf.getTrimmed(confKey); + if (StringUtils.isNotEmpty(confValue)) { + return null; + } + String suffixedConfKey = OmUtils.addKeySuffixes( + confKey, omNodeId); + confValue = conf.getTrimmed(suffixedConfKey); + if (StringUtils.isNotEmpty(confValue)) { + return confValue; + } + return null; + } + + public static String getHttpAddressForOMPeerNode(Configuration conf, + String omNodeId, String omNodeHostAddr) { + final Optional<String> bindHost = getHostNameFromConfigKeys( + conf, addKeySuffixes(OZONE_OM_HTTP_BIND_HOST_KEY, omNodeId)); + + final Optional<Integer> addressPort = getPortNumberFromConfigKeys( + conf, addKeySuffixes(OZONE_OM_HTTP_ADDRESS_KEY, omNodeId)); + + final Optional<String> addressHost = getHostNameFromConfigKeys( + conf, addKeySuffixes(OZONE_OM_HTTP_ADDRESS_KEY, omNodeId)); + + String hostName = bindHost.orElse(addressHost.orElse(omNodeHostAddr)); + + return hostName + ":" + addressPort.orElse(OZONE_OM_HTTP_BIND_PORT_DEFAULT); + } + + public static String getHttpsAddressForOMPeerNode(Configuration conf, + String omNodeId, String omNodeHostAddr) { + final Optional<String> bindHost = getHostNameFromConfigKeys( + conf, addKeySuffixes(OZONE_OM_HTTPS_BIND_HOST_KEY, omNodeId)); + + final Optional<Integer> addressPort = getPortNumberFromConfigKeys( + conf, addKeySuffixes(OZONE_OM_HTTPS_ADDRESS_KEY, omNodeId)); + + final Optional<String> addressHost = getHostNameFromConfigKeys( + conf, addKeySuffixes(OZONE_OM_HTTPS_ADDRESS_KEY, omNodeId)); + + String hostName = bindHost.orElse(addressHost.orElse(omNodeHostAddr)); + + return hostName + ":" + addressPort.orElse(OZONE_OM_HTTPS_BIND_PORT_DEFAULT); + } + + /** + * Get the local directory where ratis logs will be stored. + */ + public static String getOMRatisDirectory(Configuration conf) { + String storageDir = conf.get(OMConfigKeys.OZONE_OM_RATIS_STORAGE_DIR); + + if (Strings.isNullOrEmpty(storageDir)) { + storageDir = HddsServerUtil.getDefaultRatisDirectory(conf); + } + return storageDir; + } + + public static String getOMRatisSnapshotDirectory(Configuration conf) { + String snapshotDir = conf.get(OMConfigKeys.OZONE_OM_RATIS_SNAPSHOT_DIR); + + if (Strings.isNullOrEmpty(snapshotDir)) { + snapshotDir = getOMRatisDirectory(conf) + "/snapshot"; Review comment: We should probably use Paths.get to join the path here. Using / breaks Windows. Even though we don't officially support Windows we should make the path logic platform agnostic. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org