slfan1989 commented on code in PR #4314:
URL: https://github.com/apache/hadoop/pull/4314#discussion_r928787939


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/AppReportFetcher.java:
##########
@@ -27,81 +29,54 @@
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.client.AHSProxy;
-import org.apache.hadoop.yarn.client.ClientRMProxy;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.factories.RecordFactory;
 import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
+import org.apache.hadoop.yarn.util.StringHelper;
+import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
 
 /**
  * This class abstracts away how ApplicationReports are fetched.
  */
-public class AppReportFetcher {
-  enum AppReportSource { RM, AHS }
+public abstract class AppReportFetcher {
+
+  protected enum AppReportSource {RM, AHS}
+
   private final Configuration conf;
-  private final ApplicationClientProtocol applicationsManager;
-  private final ApplicationHistoryProtocol historyManager;
+  private ApplicationHistoryProtocol historyManager;
+  private String ahsAppPageUrlBase;
   private final RecordFactory recordFactory = 
RecordFactoryProvider.getRecordFactory(null);
   private boolean isAHSEnabled;
 
-  /**
-   * Create a new Connection to the RM/Application History Server
-   * to fetch Application reports.
-   * @param conf the conf to use to know where the RM is.
-   */
   public AppReportFetcher(Configuration conf) {
+    this.conf = conf;
     if (conf.getBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED,
         YarnConfiguration.DEFAULT_APPLICATION_HISTORY_ENABLED)) {
-      isAHSEnabled = true;
+      this.isAHSEnabled = true;
+      String scheme = WebAppUtils.getHttpSchemePrefix(conf);
+      String historyUrl = WebAppUtils.getAHSWebAppURLWithoutScheme(conf);
+      this.ahsAppPageUrlBase = StringHelper.pjoin(scheme + historyUrl, 
"applicationhistory", "app");
     }
-    this.conf = conf;
     try {
-      applicationsManager = ClientRMProxy.createRMProxy(conf,
-          ApplicationClientProtocol.class);
-      if (isAHSEnabled) {
-        historyManager = getAHSProxy(conf);
+      if (this.isAHSEnabled) {
+        this.historyManager = getAHSProxy(conf);
       } else {
         this.historyManager = null;
       }
     } catch (IOException e) {
       throw new YarnRuntimeException(e);
     }
   }
-  
-  /**
-   * Create a direct connection to RM instead of a remote connection when
-   * the proxy is running as part of the RM. Also create a remote connection to
-   * Application History Server if it is enabled.
-   * @param conf the configuration to use
-   * @param applicationsManager what to use to get the RM reports.
-   */
-  public AppReportFetcher(Configuration conf, ApplicationClientProtocol 
applicationsManager) {
-    if (conf.getBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED,
-        YarnConfiguration.DEFAULT_APPLICATION_HISTORY_ENABLED)) {
-      isAHSEnabled = true;
-    }
-    this.conf = conf;
-    this.applicationsManager = applicationsManager;
-    if (isAHSEnabled) {
-      try {
-        historyManager = getAHSProxy(conf);
-      } catch (IOException e) {
-        throw new YarnRuntimeException(e);
-      }
-    } else {
-      this.historyManager = null;
-    }
-  }
 
   protected ApplicationHistoryProtocol getAHSProxy(Configuration configuration)
       throws IOException {
-    return AHSProxy.createAHSProxy(configuration,
-      ApplicationHistoryProtocol.class,
-      configuration.getSocketAddr(YarnConfiguration.TIMELINE_SERVICE_ADDRESS,
-        YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ADDRESS,
-        YarnConfiguration.DEFAULT_TIMELINE_SERVICE_PORT));
+    return AHSProxy.createAHSProxy(configuration, 
ApplicationHistoryProtocol.class,
+        configuration.getSocketAddr(YarnConfiguration.TIMELINE_SERVICE_ADDRESS,
+            YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ADDRESS,
+            YarnConfiguration.DEFAULT_TIMELINE_SERVICE_PORT));

Review Comment:
   indentation.



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