From 83fd33d5fe847b1daa2d8e8e98329484a02078f3 Mon Sep 17 00:00:00 2001 From: Junping Du Date: Thu, 21 Jan 2016 10:52:15 -0800 Subject: [PATCH] YARN-4623. TestSystemMetricsPublisher#testPublishAppAttemptMetricsForUnmanagedAM fails with NPE on branch-2.7. Contributed by Naganarasimha G R. --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../resourcemanager/metrics/SystemMetricsPublisher.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 0f869e20ab7..0b6b5ae42a6 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -72,6 +72,9 @@ Release 2.7.3 - UNRELEASED YARN-4610. Reservations continue looking for one app causes other apps to starve (jlowe) + YARN-4623. TestSystemMetricsPublisher#testPublishAppAttemptMetricsForUnmanagedAM + fails with NPE on branch-2.7. (Naganarasimha G R via junping_du) + Release 2.7.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/SystemMetricsPublisher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/SystemMetricsPublisher.java index fbb4a8a50e2..5cb8a3c1a90 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/SystemMetricsPublisher.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/SystemMetricsPublisher.java @@ -160,6 +160,8 @@ public class SystemMetricsPublisher extends CompositeService { public void appAttemptFinished(RMAppAttempt appAttempt, RMAppAttemptState appAttemtpState, RMApp app, long finishedTime) { if (publishSystemMetrics) { + ContainerId container = (appAttempt.getMasterContainer() == null) ? null + : appAttempt.getMasterContainer().getId(); dispatcher.getEventHandler().handle( new AppAttemptFinishedEvent( appAttempt.getAppAttemptId(), @@ -171,7 +173,7 @@ public class SystemMetricsPublisher extends CompositeService { app.getFinalApplicationStatus(), RMServerUtils.createApplicationAttemptState(appAttemtpState), finishedTime, - appAttempt.getMasterContainer().getId())); + container)); } }