From 649deb72fbb62568b4ea0d67444df6faaaed169d Mon Sep 17 00:00:00 2001 From: Varun Saxena Date: Sat, 11 Feb 2017 19:21:45 +0530 Subject: [PATCH] YARN-6170. TimelineReaderServer should wait to join with HttpServer2 (Sangjin Lee via Varun Saxena) --- .../reader/TimelineReaderServer.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderServer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderServer.java index 76f7495ab5a..2835c1b2959 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderServer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderServer.java @@ -110,6 +110,16 @@ public class TimelineReaderServer extends CompositeService { startTimelineReaderWebApp(); } + private void join() { + // keep the main thread that started the server up until it receives a stop + // signal + if (readerWebServer != null) { + try { + readerWebServer.join(); + } catch (InterruptedException ignore) {} + } + } + @Override protected void serviceStop() throws Exception { if (readerWebServer != null) { @@ -194,6 +204,7 @@ public class TimelineReaderServer extends CompositeService { Configuration conf = new YarnConfiguration(); conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true); conf.setFloat(YarnConfiguration.TIMELINE_SERVICE_VERSION, 2.0f); - startTimelineReaderServer(args, conf); + TimelineReaderServer server = startTimelineReaderServer(args, conf); + server.join(); } } \ No newline at end of file