YARN-9327. Improve synchronisation in ProtoUtils#convertToProtoFormat block. Contributed by Bibin A Chundatt.
(cherry picked from commit 0c8813f135f8c17f88660bb92529c15bb3a157ca)
This commit is contained in:
parent
46b81a982b
commit
d2a5749482
@ -400,7 +400,7 @@ public static ContainerUpdateType convertFromProtoFormat(
|
|||||||
/*
|
/*
|
||||||
* Resource
|
* Resource
|
||||||
*/
|
*/
|
||||||
public static synchronized ResourceProto convertToProtoFormat(Resource r) {
|
public static ResourceProto convertToProtoFormat(Resource r) {
|
||||||
return ResourcePBImpl.getProto(r);
|
return ResourcePBImpl.getProto(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,14 +71,14 @@ public ResourcePBImpl(ResourceProto proto) {
|
|||||||
initResources();
|
initResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceProto getProto() {
|
synchronized public ResourceProto getProto() {
|
||||||
mergeLocalToProto();
|
mergeLocalToProto();
|
||||||
proto = viaProto ? proto : builder.build();
|
proto = viaProto ? proto : builder.build();
|
||||||
viaProto = true;
|
viaProto = true;
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeInitBuilder() {
|
synchronized private void maybeInitBuilder() {
|
||||||
if (viaProto || builder == null) {
|
if (viaProto || builder == null) {
|
||||||
builder = ResourceProto.newBuilder(proto);
|
builder = ResourceProto.newBuilder(proto);
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ public void setVirtualCores(int vCores) {
|
|||||||
resources[VCORES_INDEX].setValue(vCores);
|
resources[VCORES_INDEX].setValue(vCores);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initResources() {
|
synchronized private void initResources() {
|
||||||
if (this.resources != null) {
|
if (this.resources != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user