smengcl commented on a change in pull request #2565:
URL: https://github.com/apache/ozone/pull/2565#discussion_r695911494



##########
File path: 
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java
##########
@@ -76,21 +87,39 @@ public boolean isFSOEnabled() {
   public String getReconWebAddress() {
     OzoneConfiguration conf = parent.getOzoneConf();
     String protocolPrefix = "";
-    InetSocketAddress reconSocket = null;
-    if (OzoneSecurityUtil.isHttpSecurityEnabled(conf)) {
+    HttpConfig.Policy webPolicy = getHttpPolicy(conf);
+
+    String name = null;
+
+    if (webPolicy == HttpConfig.Policy.HTTPS_ONLY) {
       protocolPrefix = "https://";;
-      reconSocket = HddsUtils.getReconHTTPSAddresses(conf);
+      name = conf.get(OZONE_RECON_HTTPS_ADDRESS_KEY,
+          OZONE_RECON_HTTPS_ADDRESS_DEFAULT);
     } else {
       protocolPrefix = "http://";;
-      reconSocket = HddsUtils.getReconHTTPAddresses(conf);
+      name = conf.get(OZONE_RECON_HTTP_ADDRESS_KEY,
+          OZONE_RECON_HTTP_ADDRESS_DEFAULT);
+    }
+
+    if (StringUtils.isEmpty(name)) {
+      return null;
+    }
+
+    String reconDefaultAddress = conf.get(OZONE_RECON_ADDRESS_KEY,
+        OZONE_RECON_ADDRESS_DEFAULT);
+    Optional<String> hostname = getHostName(reconDefaultAddress);
+    if (!hostname.isPresent()) {
+      throw new IllegalArgumentException("Invalid hostname for Recon: "
+          + reconDefaultAddress);
     }
-    return protocolPrefix + reconSocket.getHostName()
-        + ":" + reconSocket.getPort();
+
+    int port = getHostPort(name).orElse(OZONE_RECON_DATANODE_PORT_DEFAULT);
+    return protocolPrefix + hostname.get() + ":" + port;
   }
 
-  public boolean isSecurityEnabled() {
+  public boolean isHTTPSEnabled() {
     OzoneConfiguration conf = parent.getOzoneConf();
-    return OzoneSecurityUtil.isHttpSecurityEnabled(conf);
+    return getHttpPolicy(conf) == HttpConfig.Policy.HTTPS_ONLY;

Review comment:
       `|| this == HttpConfig.Policy.HTTP_AND_HTTPS`
   
   Also, why not use `getHttpPolicy(conf).isHttpsEnabled()` directly?
   
   
https://github.com/apache/ozone/blob/79a9d39da7f33e71bc00183e280105562354cca4/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/http/HttpConfig.java#L59




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

Reply via email to