HDFS-4827. Slight update to the implementation of API for handling favored nodes in DFSClient. Contributed by Devaraj Das.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1487093 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Devaraj Das 2013-05-28 20:17:39 +00:00
parent 45b9d19f9d
commit 4bb72210c2
3 changed files with 9 additions and 16 deletions

View File

@ -894,6 +894,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

@ -1278,7 +1278,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

@ -341,20 +341,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.
@ -516,11 +511,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);