YARN-5921. Incorrect synchronization in RMContextImpl#setHAServiceState/getHAServiceState. Contributed by Varun Saxena
(cherry picked from commit f3b8ff54ab
)
This commit is contained in:
parent
7dc22dbe0c
commit
5b44b0c9ed
|
@ -73,6 +73,8 @@ public class RMContextImpl implements RMContext {
|
||||||
private RMApplicationHistoryWriter rmApplicationHistoryWriter;
|
private RMApplicationHistoryWriter rmApplicationHistoryWriter;
|
||||||
private SystemMetricsPublisher systemMetricsPublisher;
|
private SystemMetricsPublisher systemMetricsPublisher;
|
||||||
|
|
||||||
|
private final Object haServiceStateLock = new Object();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor. To be used in conjunction with setter methods for
|
* Default constructor. To be used in conjunction with setter methods for
|
||||||
* individual fields.
|
* individual fields.
|
||||||
|
@ -237,9 +239,9 @@ public class RMContextImpl implements RMContext {
|
||||||
this.isHAEnabled = isHAEnabled;
|
this.isHAEnabled = isHAEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setHAServiceState(HAServiceState haServiceState) {
|
void setHAServiceState(HAServiceState serviceState) {
|
||||||
synchronized (haServiceState) {
|
synchronized (haServiceStateLock) {
|
||||||
this.haServiceState = haServiceState;
|
this.haServiceState = serviceState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +337,7 @@ public class RMContextImpl implements RMContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HAServiceState getHAServiceState() {
|
public HAServiceState getHAServiceState() {
|
||||||
synchronized (haServiceState) {
|
synchronized (haServiceStateLock) {
|
||||||
return haServiceState;
|
return haServiceState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue