From 489f85933c508bc26de607b921e56e23b979fce8 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Tue, 16 May 2017 09:26:44 -0500 Subject: [PATCH] YARN-6603. NPE in RMAppsBlock. Contributed by Jason Lowe --- .../resourcemanager/webapp/RMAppsBlock.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMAppsBlock.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMAppsBlock.java index 305f1d5acc3..6a1829652c0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMAppsBlock.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMAppsBlock.java @@ -31,6 +31,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; +import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; import org.apache.hadoop.yarn.server.webapp.AppsBlock; import org.apache.hadoop.yarn.server.webapp.dao.AppInfo; @@ -96,13 +97,15 @@ public class RMAppsBlock extends AppsBlock { } String blacklistedNodesCount = "N/A"; - RMAppAttempt appAttempt = - rm.getRMContext().getRMApps().get(appAttemptId.getApplicationId()) - .getAppAttempts().get(appAttemptId); - Set nodes = - null == appAttempt ? null : appAttempt.getBlacklistedNodes(); - if (nodes != null) { - blacklistedNodesCount = String.valueOf(nodes.size()); + RMApp rmApp = rm.getRMContext().getRMApps() + .get(appAttemptId.getApplicationId()); + if (rmApp != null) { + RMAppAttempt appAttempt = rmApp.getRMAppAttempt(appAttemptId); + Set nodes = + null == appAttempt ? null : appAttempt.getBlacklistedNodes(); + if (nodes != null) { + blacklistedNodesCount = String.valueOf(nodes.size()); + } } String percent = StringUtils.format("%.1f", app.getProgress()); appsTableData