ソースを参照

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/branches/branch-1@1293422 13f79535-47bb-0310-9956-ffa450edef68
Eli Collins 13 年 前
コミット
57dda44906
2 ファイル変更8 行追加4 行削除
  1. 2 0
      CHANGES.txt
  2. 6 4
      src/hdfs/org/apache/hadoop/hdfs/DFSClient.java

+ 2 - 0
CHANGES.txt

@@ -93,6 +93,8 @@ Release 1.1.0 - unreleased
 
     HDFS-2869. Fix an error in the webhdfs docs for the mkdir op (harsh)
 
+    HDFS-3008. Negative caching of local addrs doesn't work. (eli)
+
   IMPROVEMENTS
 
     MAPREDUCE-3597. [Rumen] Provide a way to access other info of history file

+ 6 - 4
src/hdfs/org/apache/hadoop/hdfs/DFSClient.java

@@ -371,11 +371,12 @@ public class DFSClient implements FSConstants, 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;
     }
 
     // Check if the address is any local or loop back
@@ -390,7 +391,8 @@ public class DFSClient implements FSConstants, java.io.Closeable {
       }
     }
     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;