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:
parent
346d50782d
commit
f01ede227f
@ -349,6 +349,10 @@ Release 2.0.0 - UNRELEASED
|
|||||||
HADOOP-8270. hadoop-daemon.sh stop action should return 0 for an
|
HADOOP-8270. hadoop-daemon.sh stop action should return 0 for an
|
||||||
already stopped service. (Roman Shaposhnik via eli)
|
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
|
BREAKDOWN OF HADOOP-7454 SUBTASKS
|
||||||
|
|
||||||
HADOOP-7455. HA: Introduce HA Service Protocol Interface. (suresh)
|
HADOOP-7455. HA: Introduce HA Service Protocol Interface. (suresh)
|
||||||
|
@ -662,8 +662,8 @@ static private void swap(Node[] nodes, int i, int j) {
|
|||||||
*/
|
*/
|
||||||
public void pseudoSortByDistance( Node reader, Node[] nodes ) {
|
public void pseudoSortByDistance( Node reader, Node[] nodes ) {
|
||||||
int tempIndex = 0;
|
int tempIndex = 0;
|
||||||
|
int localRackNode = -1;
|
||||||
if (reader != null ) {
|
if (reader != null ) {
|
||||||
int localRackNode = -1;
|
|
||||||
//scan the array to find the local node & local rack node
|
//scan the array to find the local node & local rack node
|
||||||
for(int i=0; i<nodes.length; i++) {
|
for(int i=0; i<nodes.length; i++) {
|
||||||
if(tempIndex == 0 && reader == nodes[i]) { //local node
|
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
|
// 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));
|
swap(nodes, 0, r.nextInt(nodes.length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user