From aaf27132350547fcde1fdb372f19626838f44bc4 Mon Sep 17 00:00:00 2001 From: Xiaoyu Yao Date: Tue, 14 Feb 2017 12:52:34 -0800 Subject: [PATCH] HDFS-11409. DatanodeInfo getNetworkLocation and setNetworkLocation shoud use volatile instead of synchronized. Contributed by Chen Liang. --- .../java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java index 41735b11142..acbcffa6f03 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java @@ -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 dependentHostNames = new LinkedList<>(); private String upgradeDomain; @@ -293,11 +293,11 @@ public class DatanodeInfo extends DatanodeID implements Node { /** 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); }