[
https://issues.apache.org/jira/browse/YARN-11153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17579264#comment-17579264
]
ASF GitHub Bot commented on YARN-11153:
---------------------------------------
goiri commented on code in PR #4314:
URL: https://github.com/apache/hadoop/pull/4314#discussion_r945172390
##########
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:
I think the cleanest is to do:
```
InetSocketAddress addr =
configuration.getSocketAddr(YarnConfiguration.TIMELINE_SERVICE_ADDRESS,
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ADDRESS,
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_PORT)
return AHSProxy.createAHSProxy(configuration,
ApplicationHistoryProtocol.class, addr);
```
> Make proxy server support YARN federation.
> ------------------------------------------
>
> Key: YARN-11153
> URL: https://issues.apache.org/jira/browse/YARN-11153
> Project: Hadoop YARN
> Issue Type: Sub-task
> Components: yarn
> Affects Versions: 3.2.1
> Reporter: zhengchenyu
> Assignee: zhengchenyu
> Priority: Major
> Labels: pull-request-available
> Fix For: 3.4.0
>
> Time Spent: 8h 40m
> Remaining Estimate: 0h
>
> Detail message see: https://issues.apache.org/jira/browse/YARN-10775 and
> YARN-10775-design-doc.001.pdf
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]