ApplicationHistoryServer extends CompositeService { @Private @VisibleForTesting public int getPort() { return this.getListenerAddress().getPort(); } ApplicationHistoryServer(); @Private @VisibleForTesting int getPort(); @Private @VisibleForTesting TimelineStore getTimelineStore(); static void main(String[] args); static final int SHUTDOWN_HOOK_PRIORITY; }
@Test(timeout = 240000) public void testHostedUIs() throws Exception { ApplicationHistoryServer historyServer = new ApplicationHistoryServer(); Configuration config = new YarnConfiguration(); config.setClass(YarnConfiguration.TIMELINE_SERVICE_STORE, MemoryTimelineStore.class, TimelineStore.class); config.setClass(YarnConfiguration.TIMELINE_SERVICE_STATE_STORE_CLASS, MemoryTimelineStateStore.class, TimelineStateStore.class); config.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, "localhost:0"); final String UI1 = "UI1"; String connFileStr = ""; File diskFile = new File("./pom.xml"); String diskFileStr = readInputStream(new FileInputStream(diskFile)); try { config.set(YarnConfiguration.TIMELINE_SERVICE_UI_NAMES, UI1); config.set(YarnConfiguration.TIMELINE_SERVICE_UI_WEB_PATH_PREFIX + UI1, "/" + UI1); config.set(YarnConfiguration.TIMELINE_SERVICE_UI_ON_DISK_PATH_PREFIX + UI1, "./"); historyServer.init(config); historyServer.start(); URL url = new URL("http: + UI1 + "/pom.xml"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.connect(); assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode()); connFileStr = readInputStream(conn.getInputStream()); } finally { historyServer.stop(); } assertEquals("Web file contents should be the same as on disk contents", diskFileStr, connFileStr); }