From a0b7abf278c147d3ae7821c6783a85cb972c6ec2 Mon Sep 17 00:00:00 2001 From: Weiwei Yang Date: Mon, 7 May 2018 11:33:14 +0800 Subject: [PATCH] YARN-8025. UsersManangers#getComputedResourceLimitForActiveUsers throws NPE due to preComputedActiveUserLimit is empty. Contributed by Tao Yang. (Cherry picked from commit 67f239c42f676237290d18ddbbc9aec369267692) --- .../resourcemanager/scheduler/capacity/UsersManager.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 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/scheduler/capacity/UsersManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/UsersManager.java index 33f30b00412..b2b6e79704e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/UsersManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/UsersManager.java @@ -490,11 +490,12 @@ public class UsersManager implements AbstractUsersManager { Resource clusterResource, String nodePartition, SchedulingMode schedulingMode) { - Map userLimitPerSchedulingMode = preComputedActiveUserLimit - .get(nodePartition); + Map userLimitPerSchedulingMode; try { writeLock.lock(); + userLimitPerSchedulingMode = + preComputedActiveUserLimit.get(nodePartition); if (isRecomputeNeeded(schedulingMode, nodePartition, true)) { // recompute userLimitPerSchedulingMode = reComputeUserLimits(userName, @@ -548,11 +549,11 @@ public class UsersManager implements AbstractUsersManager { Resource clusterResource, String nodePartition, SchedulingMode schedulingMode) { - Map userLimitPerSchedulingMode = preComputedAllUserLimit - .get(nodePartition); + Map userLimitPerSchedulingMode; try { writeLock.lock(); + userLimitPerSchedulingMode = preComputedAllUserLimit.get(nodePartition); if (isRecomputeNeeded(schedulingMode, nodePartition, false)) { // recompute userLimitPerSchedulingMode = reComputeUserLimits(userName,