From f0a6d06485102ae6a58c46ee0b3b0aac8fcc0d74 Mon Sep 17 00:00:00 2001 From: Robert Joseph Evans Date: Mon, 19 Nov 2012 16:41:11 +0000 Subject: [PATCH] YARN-219. NM should aggregate logs when application finishes. (bobby) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1411289 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 2 ++ .../logaggregation/AppLogAggregatorImpl.java | 18 ++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 63a7142371..c9652d8464 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -247,6 +247,8 @@ Release 0.23.5 - UNRELEASED YARN-212. NM state machine ignores an APPLICATION_CONTAINER_FINISHED event when it shouldn't (Nathan Roberts via jlowe) + YARN-219. NM should aggregate logs when application finishes. (bobby) + Release 0.23.4 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/AppLogAggregatorImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/AppLogAggregatorImpl.java index 5f3c4dfa84..f9a0558563 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/AppLogAggregatorImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/AppLogAggregatorImpl.java @@ -149,16 +149,13 @@ private void doAppLogAggregation() { ContainerId containerId; while (!this.appFinishing.get()) { - try { - containerId = this.pendingContainers.poll(); - if (containerId == null) { - Thread.sleep(THREAD_SLEEP_TIME); - } else { - uploadLogsForContainer(containerId); + synchronized(this) { + try { + wait(THREAD_SLEEP_TIME); + } catch (InterruptedException e) { + LOG.warn("PendingContainers queue is interrupted"); + this.appFinishing.set(true); } - } catch (InterruptedException e) { - LOG.warn("PendingContainers queue is interrupted"); - this.appFinishing.set(true); } } @@ -251,8 +248,9 @@ public void startContainerLogAggregation(ContainerId containerId, } @Override - public void finishLogAggregation() { + public synchronized void finishLogAggregation() { LOG.info("Application just finished : " + this.applicationId); this.appFinishing.set(true); + this.notifyAll(); } }