HDFS-11860. Ozone: SCM: SCMContainerPlacementCapacity#chooseNode sometimes does not remove chosen node from healthy list. Contributed by Xiaoyu Yao.

This commit is contained in:
Xiaoyu Yao 2017-05-22 13:18:04 -07:00 committed by Owen O'Malley
parent a0f51ee3d7
commit 56966a0535
1 changed files with 11 additions and 11 deletions

View File

@ -112,22 +112,22 @@ public final class SCMContainerPlacementCapacity extends SCMCommonPolicy {
int firstNodeNdx = getRand().nextInt(healthyNodes.size()); int firstNodeNdx = getRand().nextInt(healthyNodes.size());
int secondNodeNdx = getRand().nextInt(healthyNodes.size()); int secondNodeNdx = getRand().nextInt(healthyNodes.size());
DatanodeID chosenID;
// There is a possibility that both numbers will be same. // There is a possibility that both numbers will be same.
// if that is so, we just return the node. // if that is so, we just return the node.
if (firstNodeNdx == secondNodeNdx) { if (firstNodeNdx == secondNodeNdx) {
return healthyNodes.get(firstNodeNdx); chosenID = healthyNodes.get(firstNodeNdx);
} else {
DatanodeID firstNodeID = healthyNodes.get(firstNodeNdx);
DatanodeID secondNodeID = healthyNodes.get(secondNodeNdx);
SCMNodeMetric firstNodeMetric =
getNodeManager().getNodeStat(firstNodeID);
SCMNodeMetric secondNodeMetric =
getNodeManager().getNodeStat(secondNodeID);
chosenID = firstNodeMetric.isGreater(secondNodeMetric.get())
? firstNodeID : secondNodeID;
} }
DatanodeID firstNodeID = healthyNodes.get(firstNodeNdx);
DatanodeID secondNodeID = healthyNodes.get(secondNodeNdx);
SCMNodeMetric firstNodeMetric = getNodeManager().getNodeStat(firstNodeID);
SCMNodeMetric secondNodeMetric = getNodeManager().getNodeStat(secondNodeID);
DatanodeID chosenID = firstNodeMetric.isGreater(secondNodeMetric.get())
? firstNodeID : secondNodeID;
healthyNodes.remove(chosenID); healthyNodes.remove(chosenID);
return chosenID; return chosenID;
} }
} }