HDFS-4898. BlockPlacementPolicyWithNodeGroup.chooseRemoteRack() fails to properly fallback to local rack.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1514156 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2013-08-15 04:52:52 +00:00
parent d0b61a169e
commit 0182ea16d3
2 changed files with 11 additions and 7 deletions

View File

@ -324,6 +324,9 @@ Release 2.1.1-beta - UNRELEASED
HDFS-5051. nn fails to download checkpointed image from snn in some HDFS-5051. nn fails to download checkpointed image from snn in some
setups. (Vinay and suresh via suresh) setups. (Vinay and suresh via suresh)
HDFS-4898. BlockPlacementPolicyWithNodeGroup.chooseRemoteRack() fails to
properly fallback to local rack. (szetszwo)
Release 2.1.0-beta - 2013-08-06 Release 2.1.0-beta - 2013-08-06
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -169,16 +169,17 @@ protected void chooseRemoteRack(int numOfReplicas,
long blocksize, int maxReplicasPerRack, List<DatanodeDescriptor> results, long blocksize, int maxReplicasPerRack, List<DatanodeDescriptor> results,
boolean avoidStaleNodes) throws NotEnoughReplicasException { boolean avoidStaleNodes) throws NotEnoughReplicasException {
int oldNumOfReplicas = results.size(); int oldNumOfReplicas = results.size();
// randomly choose one node from remote racks
final String rackLocation = NetworkTopology.getFirstHalf(
localMachine.getNetworkLocation());
try { try {
chooseRandom( // randomly choose from remote racks
numOfReplicas, chooseRandom(numOfReplicas, "~" + rackLocation, excludedNodes, blocksize,
"~" + NetworkTopology.getFirstHalf(localMachine.getNetworkLocation()), maxReplicasPerRack, results, avoidStaleNodes);
excludedNodes, blocksize, maxReplicasPerRack, results,
avoidStaleNodes);
} catch (NotEnoughReplicasException e) { } catch (NotEnoughReplicasException e) {
// fall back to the local rack
chooseRandom(numOfReplicas - (results.size() - oldNumOfReplicas), chooseRandom(numOfReplicas - (results.size() - oldNumOfReplicas),
localMachine.getNetworkLocation(), excludedNodes, blocksize, rackLocation, excludedNodes, blocksize,
maxReplicasPerRack, results, avoidStaleNodes); maxReplicasPerRack, results, avoidStaleNodes);
} }
} }