HDFS-11409. DatanodeInfo getNetworkLocation and setNetworkLocation shoud use volatile instead of synchronized. Contributed by Chen Liang.

This commit is contained in:
Xiaoyu Yao 2017-02-14 12:52:34 -08:00
parent 0cf5993712
commit aaf2713235

View File

@ -51,7 +51,7 @@ public class DatanodeInfo extends DatanodeID implements Node {
private long lastUpdate;
private long lastUpdateMonotonic;
private int xceiverCount;
private String location = NetworkTopology.DEFAULT_RACK;
private volatile String location = NetworkTopology.DEFAULT_RACK;
private String softwareVersion;
private List<String> dependentHostNames = new LinkedList<>();
private String upgradeDomain;
@ -293,11 +293,11 @@ public void setXceiverCount(int xceiverCount) {
/** network location */
@Override
public synchronized String getNetworkLocation() {return location;}
public String getNetworkLocation() {return location;}
/** Sets the network location */
@Override
public synchronized void setNetworkLocation(String location) {
public void setNetworkLocation(String location) {
this.location = NodeBase.normalize(location);
}