diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java index dc8f7d1ea0..3f17ac69a8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java @@ -80,6 +80,8 @@ public class RMContextImpl implements RMContext { private QueueLimitCalculator queueLimitCalculator; + private final Object haServiceStateLock = new Object(); + /** * Default constructor. To be used in conjunction with setter methods for * individual fields. @@ -254,9 +256,9 @@ void setHAEnabled(boolean isHAEnabled) { this.isHAEnabled = isHAEnabled; } - void setHAServiceState(HAServiceState haServiceState) { - synchronized (haServiceState) { - this.haServiceState = haServiceState; + void setHAServiceState(HAServiceState serviceState) { + synchronized (haServiceStateLock) { + this.haServiceState = serviceState; } } @@ -352,7 +354,7 @@ public boolean isHAEnabled() { @Override public HAServiceState getHAServiceState() { - synchronized (haServiceState) { + synchronized (haServiceStateLock) { return haServiceState; } }