YARN-9327. Improve synchronisation in ProtoUtils#convertToProtoFormat block. Contributed by Bibin A Chundatt.

This commit is contained in:
Sunil G 2019-07-02 11:44:11 +05:30
parent 570eee30e5
commit 0c8813f135
2 changed files with 4 additions and 4 deletions

View File

@ -412,7 +412,7 @@ public static ContainerUpdateType convertFromProtoFormat(
/*
* Resource
*/
public static synchronized ResourceProto convertToProtoFormat(Resource r) {
public static ResourceProto convertToProtoFormat(Resource r) {
return ResourcePBImpl.getProto(r);
}

View File

@ -75,14 +75,14 @@ public ResourcePBImpl(ResourceProto proto) {
initResources();
}
public ResourceProto getProto() {
synchronized public ResourceProto getProto() {
mergeLocalToProto();
proto = viaProto ? proto : builder.build();
viaProto = true;
return proto;
}
private void maybeInitBuilder() {
synchronized private void maybeInitBuilder() {
if (viaProto || builder == null) {
builder = ResourceProto.newBuilder(proto);
}
@ -131,7 +131,7 @@ public void setVirtualCores(int vCores) {
resources[VCORES_INDEX].setValue(vCores);
}
private void initResources() {
synchronized private void initResources() {
if (this.resources != null) {
return;
}