YARN-6376. Exceptions caused by synchronous putEntities requests can be 
swallowed (Haibo Chen via Varun Saxena)

(cherry picked from commit b58777a9c9a5b6f2e4bcfd2b3bede33f25f80dec)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d7a4420f
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d7a4420f
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d7a4420f

Branch: refs/heads/YARN-5355_branch2
Commit: d7a4420fdda50f0631ced9ba7080823c57f495fd
Parents: 88304a9
Author: Varun Saxena <varunsax...@apache.org>
Authored: Fri Mar 31 02:17:20 2017 +0530
Committer: Varun Saxena <varunsax...@apache.org>
Committed: Thu Aug 31 01:10:04 2017 +0530

----------------------------------------------------------------------
 .../timelineservice/collector/TimelineCollector.java      | 10 ++++++++--
 .../collector/TimelineCollectorManager.java               |  7 ++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/d7a4420f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/collector/TimelineCollector.java
----------------------------------------------------------------------
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/collector/TimelineCollector.java
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/collector/TimelineCollector.java
index 353066b..4c9e9f8 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/collector/TimelineCollector.java
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/collector/TimelineCollector.java
@@ -137,8 +137,14 @@ public abstract class TimelineCollector extends 
CompositeService {
           + callerUgi + ")");
     }
 
-    TimelineWriteResponse response = writeTimelineEntities(entities);
-    flushBufferedTimelineEntities();
+    TimelineWriteResponse response;
+    // synchronize on the writer object so that no other threads can
+    // flush the writer buffer concurrently and swallow any exception
+    // caused by the timeline enitites that are being put here.
+    synchronized (writer) {
+      response = writeTimelineEntities(entities);
+      flushBufferedTimelineEntities();
+    }
 
     return response;
   }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/d7a4420f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/collector/TimelineCollectorManager.java
----------------------------------------------------------------------
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/collector/TimelineCollectorManager.java
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/collector/TimelineCollectorManager.java
index 19896e8..8ef9b43 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/collector/TimelineCollectorManager.java
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/collector/TimelineCollectorManager.java
@@ -259,7 +259,12 @@ public class TimelineCollectorManager extends 
AbstractService {
 
     public void run() {
       try {
-        writer.flush();
+        // synchronize on the writer object to avoid flushing timeline
+        // entities placed on the buffer by synchronous putEntities
+        // requests.
+        synchronized (writer) {
+          writer.flush();
+        }
       } catch (Throwable th) {
         // we need to handle all exceptions or subsequent execution may be
         // suppressed


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to