YARN-6603. NPE in RMAppsBlock. Contributed by Jason Lowe

This commit is contained in:
Jason Lowe 2017-05-16 09:26:44 -05:00
parent c48f2976a3
commit 489f85933c
1 changed files with 10 additions and 7 deletions

View File

@ -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.ApplicationReport;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; 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.resourcemanager.rmapp.attempt.RMAppAttempt;
import org.apache.hadoop.yarn.server.webapp.AppsBlock; import org.apache.hadoop.yarn.server.webapp.AppsBlock;
import org.apache.hadoop.yarn.server.webapp.dao.AppInfo; import org.apache.hadoop.yarn.server.webapp.dao.AppInfo;
@ -96,14 +97,16 @@ public class RMAppsBlock extends AppsBlock {
} }
String blacklistedNodesCount = "N/A"; String blacklistedNodesCount = "N/A";
RMAppAttempt appAttempt = RMApp rmApp = rm.getRMContext().getRMApps()
rm.getRMContext().getRMApps().get(appAttemptId.getApplicationId()) .get(appAttemptId.getApplicationId());
.getAppAttempts().get(appAttemptId); if (rmApp != null) {
RMAppAttempt appAttempt = rmApp.getRMAppAttempt(appAttemptId);
Set<String> nodes = Set<String> nodes =
null == appAttempt ? null : appAttempt.getBlacklistedNodes(); null == appAttempt ? null : appAttempt.getBlacklistedNodes();
if (nodes != null) { if (nodes != null) {
blacklistedNodesCount = String.valueOf(nodes.size()); blacklistedNodesCount = String.valueOf(nodes.size());
} }
}
String percent = StringUtils.format("%.1f", app.getProgress()); String percent = StringUtils.format("%.1f", app.getProgress());
appsTableData appsTableData
.append("[\"<a href='") .append("[\"<a href='")