From 296c5de0cfee88389cf9f90263280b2034e54cd5 Mon Sep 17 00:00:00 2001 From: Rohith Sharma K S Date: Tue, 15 Nov 2016 10:56:28 +0530 Subject: [PATCH] YARN-5873. RM crashes with NPE if generic application history is enabled. Contributed by Varun Saxena. --- .../resourcemanager/rmcontainer/RMContainerImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java index a651d54828a..f5d8b5b0633 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java @@ -247,7 +247,9 @@ public class RMContainerImpl implements RMContainer, Comparable { YarnConfiguration .DEFAULT_APPLICATION_HISTORY_SAVE_NON_AM_CONTAINER_META_INFO); - rmContext.getRMApplicationHistoryWriter().containerStarted(this); + if (container.getId() != null) { + rmContext.getRMApplicationHistoryWriter().containerStarted(this); + } // If saveNonAMContainerMetaInfo is true, store system metrics for all // containers. If false, and if this container is marked as the AM, metrics @@ -892,6 +894,9 @@ public class RMContainerImpl implements RMContainer, Comparable { // container creation event to timeline service when id assigned. container.setId(containerId); + if (containerId != null) { + rmContext.getRMApplicationHistoryWriter().containerStarted(this); + } // If saveNonAMContainerMetaInfo is true, store system metrics for all // containers. If false, and if this container is marked as the AM, metrics // will still be published for this container, but that calculation happens