HADOOP-8144. pseudoSortByDistance in NetworkTopology doesn't work properly if no local node and first node is local rack node. Contributed by Junping Du

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1325367 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2012-04-12 16:37:15 +00:00
parent 346d50782d
commit f01ede227f
2 changed files with 6 additions and 2 deletions

View File

@ -349,6 +349,10 @@ Release 2.0.0 - UNRELEASED
HADOOP-8270. hadoop-daemon.sh stop action should return 0 for an
already stopped service. (Roman Shaposhnik via eli)
HADOOP-8144. pseudoSortByDistance in NetworkTopology doesn't work
properly if no local node and first node is local rack node.
(Junping Du)
BREAKDOWN OF HADOOP-7454 SUBTASKS
HADOOP-7455. HA: Introduce HA Service Protocol Interface. (suresh)

View File

@ -662,8 +662,8 @@ static private void swap(Node[] nodes, int i, int j) {
*/
public void pseudoSortByDistance( Node reader, Node[] nodes ) {
int tempIndex = 0;
if (reader != null ) {
int localRackNode = -1;
if (reader != null ) {
//scan the array to find the local node & local rack node
for(int i=0; i<nodes.length; i++) {
if(tempIndex == 0 && reader == nodes[i]) { //local node
@ -693,7 +693,7 @@ public void pseudoSortByDistance( Node reader, Node[] nodes ) {
}
// put a random node at position 0 if it is not a local/local-rack node
if(tempIndex == 0 && nodes.length != 0) {
if(tempIndex == 0 && localRackNode == -1 && nodes.length != 0) {
swap(nodes, 0, r.nextInt(nodes.length));
}
}