From 78f22bc525679a286285dd5e70a68f9b5a6f6ed7 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Fri, 24 Feb 2012 21:14:04 +0000 Subject: [PATCH] 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 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 2 ++ .../main/java/org/apache/hadoop/hdfs/DFSClient.java | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 5d7c0096764..a5398891e33 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -280,6 +280,8 @@ Release 0.23.2 - UNRELEASED dfs.client.block.write.replace-datanode-on-failure.enable should be true. (szetszwo) + HDFS-3008. Negative caching of local addrs doesn't work. (eli) + Release 0.23.1 - 2012-02-17 INCOMPATIBLE CHANGES 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 2fae52a8507..491cd7e989a 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 @@ -542,17 +542,19 @@ public class DFSClient implements java.io.Closeable { private static boolean isLocalAddress(InetSocketAddress targetAddr) { InetAddress addr = targetAddr.getAddress(); Boolean cached = localAddrMap.get(addr.getHostAddress()); - if (cached != null && cached) { + if (cached != null) { 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); if (LOG.isTraceEnabled()) { - LOG.trace("Address " + targetAddr + " is local"); + LOG.trace("Address " + targetAddr + + (local ? " is local" : " is not local")); } localAddrMap.put(addr.getHostAddress(), local); return local;