Hello, can you help me
I am a hadoop system's user. I found a bug of
NetworkTopology::pseudoSortByDistance in version 18.0.
The bug is:
1.When the local node is not found but the local rack node is found and that
node's position in the node array is 0, a random node at position 0 is put.
2.When the local node is not found and the local rack node is not found but
the local datacenter node is found A random node at position 0 is put 3.
When it comes near most and there are two or more data node most, hadoop
can't read the data from a node arbitrary by random numbers in that
I changed the source code for fix the bug. But I can't submit the source
code file to hadoop server.
The source is:
public synchronized void pseudoSortByDistance( Node reader, Node[] nodes )
{
if(nodes.length == 0)return;
if(reader != null){
int distances[] = new int[nodes.length];
// get their distances to reader
for(int i=0;i<nodes.length; i++){
distances[i] = getDistance(reader,nodes[i]);
}
// Sort nodes array by their distances to reader
for(int i=0;i<distances.length; i++){
for(int j=i+1;j<distances.length;j++){
if(distances[i] > distances[j] ){
swap(nodes,i,j);
}
}
}
/**
* put a random node at position 0 from the nodes of
* that is equal with the first node's distance to reader
*/
int i;
for(i=0;i<distances.length;i++){
if(distances[i] != distances[0])break;
}
if(i != 0)swap(nodes, 0, r.nextInt(i));
}else{ // put a random node at position 0 if reader is null
swap(nodes, 0, r.nextInt(nodes.length));
}
}
