Merge 1550074 from trunk: HDFS-5580. Fix infinite loop in Balancer.waitForMoveCompletion. (Binglin Chang via junping_du)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1550078 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Junping Du 2013-12-11 09:13:45 +00:00
parent c9ad1bb3aa
commit 29848761ea
2 changed files with 19 additions and 15 deletions

View File

@ -196,6 +196,9 @@ Release 2.4.0 - UNRELEASED
HDFS-5533. Symlink delete/create should be treated as DELETE/CREATE in snapshot diff HDFS-5533. Symlink delete/create should be treated as DELETE/CREATE in snapshot diff
report. (Binglin Chang via jing9) report. (Binglin Chang via jing9)
HDFS-5580. Fix infinite loop in Balancer.waitForMoveCompletion.
(Binglin Chang via junping_du)
Release 2.3.0 - UNRELEASED Release 2.3.0 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -292,26 +292,27 @@ public class Balancer {
*/ */
private boolean chooseProxySource() { private boolean chooseProxySource() {
final DatanodeInfo targetDN = target.getDatanode(); final DatanodeInfo targetDN = target.getDatanode();
boolean find = false; // if node group is supported, first try add nodes in the same node group
if (cluster.isNodeGroupAware()) {
for (BalancerDatanode loc : block.getLocations()) { for (BalancerDatanode loc : block.getLocations()) {
// check if there is replica which is on the same rack with the target if (cluster.isOnSameNodeGroup(loc.getDatanode(), targetDN) && addTo(loc)) {
if (cluster.isOnSameRack(loc.getDatanode(), targetDN) && addTo(loc)) {
find = true;
// if cluster is not nodegroup aware or the proxy is on the same
// nodegroup with target, then we already find the nearest proxy
if (!cluster.isNodeGroupAware()
|| cluster.isOnSameNodeGroup(loc.getDatanode(), targetDN)) {
return true; return true;
} }
} }
}
if (!find) { // check if there is replica which is on the same rack with the target
// find out a non-busy replica out of rack of target for (BalancerDatanode loc : block.getLocations()) {
find = addTo(loc); if (cluster.isOnSameRack(loc.getDatanode(), targetDN) && addTo(loc)) {
return true;
} }
} }
// find out a non-busy replica
return find; for (BalancerDatanode loc : block.getLocations()) {
if (addTo(loc)) {
return true;
}
}
return false;
} }
// add a BalancerDatanode as proxy source for specific block movement // add a BalancerDatanode as proxy source for specific block movement