sarvekshayr commented on code in PR #9285:
URL: https://github.com/apache/ozone/pull/9285#discussion_r2526104730


##########
hadoop-ozone/insight/src/main/java/org/apache/hadoop/ozone/insight/BaseInsightSubCommand.java:
##########
@@ -62,25 +69,37 @@ public InsightPoint getInsight(OzoneConfiguration 
configuration,
    * Utility to get the host base on a component.
    */
   public String getHost(OzoneConfiguration conf, Component component) {
+    HttpConfig.Policy policy = HttpConfig.getHttpPolicy(conf);
+    String protocol = policy.isHttpsEnabled() ? HTTPS_SCHEME : HTTP_SCHEME;
+    
     if (component.getHostname() != null) {
-      return "http://"; + component.getHostname() + ":" + component.getPort();
-    } else if (component.getName() == Type.SCM) {
-      Optional<String> scmHost =
-          HddsUtils.getHostNameFromConfigKeys(conf,
-              ScmConfigKeys.OZONE_SCM_BLOCK_CLIENT_ADDRESS_KEY,
-              ScmConfigKeys.OZONE_SCM_CLIENT_ADDRESS_KEY);
+      return protocol + "://" + component.getHostname() + ":" + 
component.getPort();
+    }
+    
+    String address = getComponentAddress(conf, component.getName(), policy);
+    return protocol + "://" + address;
+  }
 
-      return "http://"; + scmHost.get() + ":9876";
-    } else if (component.getName() == Type.OM) {
-      Optional<String> omHost =
-          HddsUtils.getHostNameFromConfigKeys(conf,
-              OMConfigKeys.OZONE_OM_ADDRESS_KEY);
-      return "http://"; + omHost.get() + ":9874";
-    } else {
+  /**
+   * Get the component address based on HTTP policy.
+   */
+  private String getComponentAddress(OzoneConfiguration conf,
+      Component.Type componentType, HttpConfig.Policy policy) {
+    boolean isHttpsEnabled = policy.isHttpsEnabled();
+    
+    switch (componentType) {
+    case SCM:
+      return isHttpsEnabled
+          ? conf.get(OZONE_SCM_HTTPS_ADDRESS_KEY, "0.0.0.0:" + 
OZONE_SCM_HTTPS_BIND_PORT_DEFAULT)
+          : conf.get(OZONE_SCM_HTTP_ADDRESS_KEY, "0.0.0.0:" + 
OZONE_SCM_HTTP_BIND_PORT_DEFAULT);
+    case OM:
+      return isHttpsEnabled
+          ? conf.get(OZONE_OM_HTTPS_ADDRESS_KEY, "0.0.0.0:" + 
OZONE_OM_HTTPS_BIND_PORT_DEFAULT)
+          : conf.get(OZONE_OM_HTTP_ADDRESS_KEY, "0.0.0.0:" + 
OZONE_OM_HTTP_BIND_PORT_DEFAULT);

Review Comment:
   Done.



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