YARN-8025. UsersManangers#getComputedResourceLimitForActiveUsers throws NPE due to preComputedActiveUserLimit is empty. Contributed by Tao Yang.

(Cherry picked from commit 67f239c42f)
This commit is contained in:
Weiwei Yang 2018-05-07 11:33:14 +08:00
parent 864640c1e3
commit 68dd01efc1
1 changed files with 5 additions and 4 deletions

View File

@ -490,11 +490,12 @@ public class UsersManager implements AbstractUsersManager {
Resource clusterResource, String nodePartition, Resource clusterResource, String nodePartition,
SchedulingMode schedulingMode) { SchedulingMode schedulingMode) {
Map<SchedulingMode, Resource> userLimitPerSchedulingMode = preComputedActiveUserLimit Map<SchedulingMode, Resource> userLimitPerSchedulingMode;
.get(nodePartition);
try { try {
writeLock.lock(); writeLock.lock();
userLimitPerSchedulingMode =
preComputedActiveUserLimit.get(nodePartition);
if (isRecomputeNeeded(schedulingMode, nodePartition, true)) { if (isRecomputeNeeded(schedulingMode, nodePartition, true)) {
// recompute // recompute
userLimitPerSchedulingMode = reComputeUserLimits(userName, userLimitPerSchedulingMode = reComputeUserLimits(userName,
@ -548,11 +549,11 @@ public class UsersManager implements AbstractUsersManager {
Resource clusterResource, String nodePartition, Resource clusterResource, String nodePartition,
SchedulingMode schedulingMode) { SchedulingMode schedulingMode) {
Map<SchedulingMode, Resource> userLimitPerSchedulingMode = preComputedAllUserLimit Map<SchedulingMode, Resource> userLimitPerSchedulingMode;
.get(nodePartition);
try { try {
writeLock.lock(); writeLock.lock();
userLimitPerSchedulingMode = preComputedAllUserLimit.get(nodePartition);
if (isRecomputeNeeded(schedulingMode, nodePartition, false)) { if (isRecomputeNeeded(schedulingMode, nodePartition, false)) {
// recompute // recompute
userLimitPerSchedulingMode = reComputeUserLimits(userName, userLimitPerSchedulingMode = reComputeUserLimits(userName,