|
@@ -26,6 +26,7 @@ import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
|
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
|
+import org.apache.hadoop.http.HttpServer2;
|
|
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
|
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
|
import org.apache.hadoop.metrics2.source.JvmMetrics;
|
|
import org.apache.hadoop.metrics2.source.JvmMetrics;
|
|
import org.apache.hadoop.security.AuthenticationFilterInitializer;
|
|
import org.apache.hadoop.security.AuthenticationFilterInitializer;
|
|
@@ -54,6 +55,8 @@ import org.apache.hadoop.yarn.server.timeline.webapp.CrossOriginFilterInitialize
|
|
import org.apache.hadoop.yarn.webapp.WebApp;
|
|
import org.apache.hadoop.yarn.webapp.WebApp;
|
|
import org.apache.hadoop.yarn.webapp.WebApps;
|
|
import org.apache.hadoop.yarn.webapp.WebApps;
|
|
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
|
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
|
|
|
+import org.mortbay.jetty.servlet.FilterHolder;
|
|
|
|
+import org.mortbay.jetty.webapp.WebAppContext;
|
|
|
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
|
|
|
@@ -137,6 +140,12 @@ public class ApplicationHistoryServer extends CompositeService {
|
|
return this.ahsClientService;
|
|
return this.ahsClientService;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Private
|
|
|
|
+ @VisibleForTesting
|
|
|
|
+ int getPort() {
|
|
|
|
+ return this.webApp.httpServer().getConnectorAddress(0).getPort();
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @return ApplicationTimelineStore
|
|
* @return ApplicationTimelineStore
|
|
*/
|
|
*/
|
|
@@ -223,6 +232,7 @@ public class ApplicationHistoryServer extends CompositeService {
|
|
timelineStore, new TimelineACLsManager(conf));
|
|
timelineStore, new TimelineACLsManager(conf));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
private void startWebApp() {
|
|
private void startWebApp() {
|
|
Configuration conf = getConfig();
|
|
Configuration conf = getConfig();
|
|
TimelineAuthenticationFilter.setTimelineDelegationTokenSecretManager(
|
|
TimelineAuthenticationFilter.setTimelineDelegationTokenSecretManager(
|
|
@@ -278,14 +288,42 @@ public class ApplicationHistoryServer extends CompositeService {
|
|
String bindAddress = WebAppUtils.getWebAppBindURL(conf,
|
|
String bindAddress = WebAppUtils.getWebAppBindURL(conf,
|
|
YarnConfiguration.TIMELINE_SERVICE_BIND_HOST,
|
|
YarnConfiguration.TIMELINE_SERVICE_BIND_HOST,
|
|
WebAppUtils.getAHSWebAppURLWithoutScheme(conf));
|
|
WebAppUtils.getAHSWebAppURLWithoutScheme(conf));
|
|
- LOG.info("Instantiating AHSWebApp at " + bindAddress);
|
|
|
|
try {
|
|
try {
|
|
|
|
+ AHSWebApp ahsWebApp = new AHSWebApp(timelineDataManager, ahsClientService);
|
|
webApp =
|
|
webApp =
|
|
WebApps
|
|
WebApps
|
|
.$for("applicationhistory", ApplicationHistoryClientService.class,
|
|
.$for("applicationhistory", ApplicationHistoryClientService.class,
|
|
ahsClientService, "ws")
|
|
ahsClientService, "ws")
|
|
- .with(conf).at(bindAddress).start(
|
|
|
|
- new AHSWebApp(timelineDataManager, ahsClientService));
|
|
|
|
|
|
+ .with(conf).withAttribute(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
|
|
|
|
+ conf.get(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS)).at(bindAddress).build(ahsWebApp);
|
|
|
|
+ HttpServer2 httpServer = webApp.httpServer();
|
|
|
|
+
|
|
|
|
+ String[] names = conf.getTrimmedStrings(YarnConfiguration.TIMELINE_SERVICE_UI_NAMES);
|
|
|
|
+ WebAppContext webAppContext = httpServer.getWebAppContext();
|
|
|
|
+
|
|
|
|
+ for (String name : names) {
|
|
|
|
+ String webPath = conf.get(
|
|
|
|
+ YarnConfiguration.TIMELINE_SERVICE_UI_WEB_PATH_PREFIX + name);
|
|
|
|
+ String onDiskPath = conf.get(
|
|
|
|
+ YarnConfiguration.TIMELINE_SERVICE_UI_ON_DISK_PATH_PREFIX + name);
|
|
|
|
+ WebAppContext uiWebAppContext = new WebAppContext();
|
|
|
|
+ uiWebAppContext.setContextPath(webPath);
|
|
|
|
+ uiWebAppContext.setWar(onDiskPath);
|
|
|
|
+ final String[] ALL_URLS = { "/*" };
|
|
|
|
+ FilterHolder[] filterHolders =
|
|
|
|
+ webAppContext.getServletHandler().getFilters();
|
|
|
|
+ for (FilterHolder filterHolder: filterHolders) {
|
|
|
|
+ if (!"guice".equals(filterHolder.getName())) {
|
|
|
|
+ HttpServer2.defineFilter(uiWebAppContext, filterHolder.getName(),
|
|
|
|
+ filterHolder.getClassName(), filterHolder.getInitParameters(),
|
|
|
|
+ ALL_URLS);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ LOG.info("Hosting " + name + " from " + onDiskPath + " at " + webPath);
|
|
|
|
+ httpServer.addContext(uiWebAppContext, true);
|
|
|
|
+ }
|
|
|
|
+ httpServer.start();
|
|
|
|
+ LOG.info("Instantiating AHSWebApp at " + getPort());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
String msg = "AHSWebApp failed to start.";
|
|
String msg = "AHSWebApp failed to start.";
|
|
LOG.error(msg, e);
|
|
LOG.error(msg, e);
|