diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 5da4999a4c..2d8662c8a7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -236,6 +236,9 @@ Release 0.23.1 - UNRELEASED HDFS-2590. Fix the missing links in the WebHDFS forrest doc. (szetszwo) HDFS-2596. TestDirectoryScanner doesn't test parallel scans. (eli) + + HDFS-2653. DFSClient should cache whether addrs are non-local when + short-circuiting is enabled. (eli) Release 0.23.0 - 2011-11-01 diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java index 5762a53d0d..fad16274de 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java @@ -33,10 +33,8 @@ import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import javax.net.SocketFactory; @@ -532,12 +530,13 @@ static BlockReader getLocalBlockReader(Configuration conf, } } - private static Set localIpAddresses = Collections - .synchronizedSet(new HashSet()); + private static Map localAddrMap = Collections + .synchronizedMap(new HashMap()); private static boolean isLocalAddress(InetSocketAddress targetAddr) { InetAddress addr = targetAddr.getAddress(); - if (localIpAddresses.contains(addr.getHostAddress())) { + Boolean cached = localAddrMap.get(addr.getHostAddress()); + if (cached != null && cached) { if (LOG.isTraceEnabled()) { LOG.trace("Address " + targetAddr + " is local"); } @@ -558,9 +557,7 @@ private static boolean isLocalAddress(InetSocketAddress targetAddr) { if (LOG.isTraceEnabled()) { LOG.trace("Address " + targetAddr + " is local"); } - if (local == true) { - localIpAddresses.add(addr.getHostAddress()); - } + localAddrMap.put(addr.getHostAddress(), local); return local; }