From 0e79131981297c29f866f325d63ffd42a4435f88 Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Fri, 24 Feb 2012 19:29:41 +0000 Subject: [PATCH] HDFS-3009. Remove duplicate code in DFSClient#isLocalAddress by using NetUtils. Contributed by Hari Mankude. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1293390 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 7 +++++-- .../main/java/org/apache/hadoop/hdfs/DFSClient.java | 13 ++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 713a861973..5d7c009676 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -132,12 +132,15 @@ Trunk (unreleased changes) HDFS-2878. Fix TestBlockRecovery and move it back into main test directory. (todd) - HDFS-2655. BlockReaderLocal#skip performs unnecessary IO. (Brandon Li - via jitendra) + HDFS-2655. BlockReaderLocal#skip performs unnecessary IO. + (Brandon Li via jitendra) HDFS-3003. Remove getHostPortString() from NameNode, replace it with NetUtils.getHostPortString(). (Brandon Li via atm) + HDFS-3009. Remove duplicate code in DFSClient#isLocalAddress by using + NetUtils. (Hari Mankude via suresh) + OPTIMIZATIONS HDFS-2477. Optimize computing the diff between a block report and the namenode state. (Tomasz Nykiel via hairong) 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 be52b48f11..2fae52a850 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 @@ -548,18 +548,9 @@ private static boolean isLocalAddress(InetSocketAddress targetAddr) { } return true; } + + boolean local = NetUtils.isLocalAddress(addr); - // Check if the address is any local or loop back - boolean local = addr.isAnyLocalAddress() || addr.isLoopbackAddress(); - - // Check if the address is defined on any interface - if (!local) { - try { - local = NetworkInterface.getByInetAddress(addr) != null; - } catch (SocketException e) { - local = false; - } - } if (LOG.isTraceEnabled()) { LOG.trace("Address " + targetAddr + " is local"); }