HDFS-3008. Negative caching of local addrs doesn't work. Contributed by Eli Collins

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1293419 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2012-02-24 21:14:04 +00:00
parent 0e79131981
commit 78f22bc525
2 changed files with 8 additions and 4 deletions

View File

@ -280,6 +280,8 @@ Release 0.23.2 - UNRELEASED
dfs.client.block.write.replace-datanode-on-failure.enable should be true. dfs.client.block.write.replace-datanode-on-failure.enable should be true.
(szetszwo) (szetszwo)
HDFS-3008. Negative caching of local addrs doesn't work. (eli)
Release 0.23.1 - 2012-02-17 Release 0.23.1 - 2012-02-17
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -542,17 +542,19 @@ static BlockReader getLocalBlockReader(Configuration conf,
private static boolean isLocalAddress(InetSocketAddress targetAddr) { private static boolean isLocalAddress(InetSocketAddress targetAddr) {
InetAddress addr = targetAddr.getAddress(); InetAddress addr = targetAddr.getAddress();
Boolean cached = localAddrMap.get(addr.getHostAddress()); Boolean cached = localAddrMap.get(addr.getHostAddress());
if (cached != null && cached) { if (cached != null) {
if (LOG.isTraceEnabled()) { if (LOG.isTraceEnabled()) {
LOG.trace("Address " + targetAddr + " is local"); LOG.trace("Address " + targetAddr +
(cached ? " is local" : " is not local"));
} }
return true; return cached;
} }
boolean local = NetUtils.isLocalAddress(addr); boolean local = NetUtils.isLocalAddress(addr);
if (LOG.isTraceEnabled()) { if (LOG.isTraceEnabled()) {
LOG.trace("Address " + targetAddr + " is local"); LOG.trace("Address " + targetAddr +
(local ? " is local" : " is not local"));
} }
localAddrMap.put(addr.getHostAddress(), local); localAddrMap.put(addr.getHostAddress(), local);
return local; return local;