Merge -r 1487092:1487093 from trunk onto branch-2. Fixes HDFS-4827.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1487099 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Devaraj Das 2013-05-28 20:25:35 +00:00
parent 419fb4a4de
commit 0c221b3b03
3 changed files with 9 additions and 16 deletions

View File

@ -290,6 +290,9 @@ Release 2.0.5-beta - UNRELEASED
HDFS-4780. Use the correct relogin method for services. (Robert Parker via
kihwal)
HDFS-4827. Slight update to the implementation of API for handling favored
nodes in DFSClient (ddas)
BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS
HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes.

View File

@ -1304,7 +1304,7 @@ public class DFSClient implements java.io.Closeable {
favoredNodeStrs = new String[favoredNodes.length];
for (int i = 0; i < favoredNodes.length; i++) {
favoredNodeStrs[i] =
favoredNodes[i].getAddress().getHostAddress() + ":"
favoredNodes[i].getHostName() + ":"
+ favoredNodes[i].getPort();
}
}

View File

@ -330,20 +330,15 @@ public class DatanodeManager {
* @return the best match for the given datanode
*/
DatanodeDescriptor getDatanodeDescriptor(String address) {
DatanodeDescriptor node = null;
int colon = address.indexOf(":");
int xferPort;
String host = address;
if (colon > 0) {
host = address.substring(0, colon);
xferPort = Integer.parseInt(address.substring(colon+1));
node = getDatanodeByXferAddr(host, xferPort);
}
DatanodeID dnId = parseDNFromHostsEntry(address);
String host = dnId.getIpAddr();
int xferPort = dnId.getXferPort();
DatanodeDescriptor node = getDatanodeByXferAddr(host, xferPort);
if (node == null) {
node = getDatanodeByHost(host);
}
if (node == null) {
String networkLocation = resolveNetworkLocation(host);
String networkLocation = resolveNetworkLocation(dnId);
// If the current cluster doesn't contain the node, fallback to
// something machine local and then rack local.
@ -505,11 +500,6 @@ public class DatanodeManager {
}
}
public String resolveNetworkLocation(String host) {
DatanodeID d = parseDNFromHostsEntry(host);
return resolveNetworkLocation(d);
}
/* Resolve a node's network location */
private String resolveNetworkLocation (DatanodeID node) {
List<String> names = new ArrayList<String>(1);