HDFS-3009. Merge r1293390 from trunk

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1492892 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2013-06-13 22:45:54 +00:00
parent e277c2a521
commit bf81643485
2 changed files with 5 additions and 11 deletions

View File

@ -169,6 +169,9 @@ Release 2.1.0-beta - UNRELEASED
HDFS-2857. Cleanup BlockInfo class. (suresh)
HDFS-3009. Remove duplicate code in DFSClient#isLocalAddress by using
NetUtils. (Hari Mankude via suresh)
OPTIMIZATIONS
BUG FIXES

View File

@ -819,18 +819,9 @@ public class DFSClient implements java.io.Closeable {
}
return cached;
}
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 +
(local ? " is local" : " is not local"));