ApplicationHistoryServer extends CompositeService { static ApplicationHistoryServer launchAppHistoryServer(String[] args) { Thread .setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler()); StringUtils.startupShutdownMessage(ApplicationHistoryServer.class, args, LOG); ApplicationHistoryServer appHistoryServer = null; try { appHistoryServer = new ApplicationHistoryServer(); ShutdownHookManager.get().addShutdownHook( new CompositeServiceShutdownHook(appHistoryServer), SHUTDOWN_HOOK_PRIORITY); YarnConfiguration conf = new YarnConfiguration(); new GenericOptionsParser(conf, args); appHistoryServer.init(conf); appHistoryServer.start(); } catch (Throwable t) { LOG.error("Error starting ApplicationHistoryServer", t); ExitUtil.terminate(-1, "Error starting ApplicationHistoryServer"); } return appHistoryServer; } ApplicationHistoryServer(); @Private @VisibleForTesting int getPort(); @Private @VisibleForTesting TimelineStore getTimelineStore(); static void main(String[] args); static final int SHUTDOWN_HOOK_PRIORITY; }
@Test(timeout = 60000) public void testLaunch() throws Exception { ExitUtil.disableSystemExit(); ApplicationHistoryServer historyServer = null; try { historyServer = ApplicationHistoryServer.launchAppHistoryServer(new String[0]); } catch (ExitUtil.ExitException e) { assertEquals(0, e.status); ExitUtil.resetFirstExitException(); fail(); } finally { if (historyServer != null) { historyServer.stop(); } } }
@Test(timeout = 60000) public void testLaunchWithArguments() throws Exception { ExitUtil.disableSystemExit(); ApplicationHistoryServer historyServer = null; try { String[] args = new String[2]; args[0]="-D" + YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS + "=4000"; args[1]="-D" + YarnConfiguration.TIMELINE_SERVICE_TTL_MS + "=200"; historyServer = ApplicationHistoryServer.launchAppHistoryServer(args); Configuration conf = historyServer.getConfig(); assertEquals("4000", conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS)); assertEquals("200", conf.get(YarnConfiguration.TIMELINE_SERVICE_TTL_MS)); } catch (ExitUtil.ExitException e) { assertEquals(0, e.status); ExitUtil.resetFirstExitException(); fail(); } finally { if (historyServer != null) { historyServer.stop(); } } }