HDDS-1637. Fix random test failure TestSCMContainerPlacementRackAware. Contributed by Sammi Chen. (#904)
This commit is contained in:
parent
d1aad44490
commit
0b1e288deb
@ -237,6 +237,7 @@ private Node chooseNode(List<Node> excludedNodes, Node affinityNode,
|
||||
long sizeRequired) throws SCMException {
|
||||
int ancestorGen = RACK_LEVEL;
|
||||
int maxRetry = MAX_RETRY;
|
||||
List<Node> excludedNodesForCapacity = null;
|
||||
while(true) {
|
||||
Node node = networkTopology.chooseRandom(NetConstants.ROOT, null,
|
||||
excludedNodes, affinityNode, ancestorGen);
|
||||
@ -265,6 +266,9 @@ private Node chooseNode(List<Node> excludedNodes, Node affinityNode,
|
||||
if (hasEnoughSpace((DatanodeDetails)node, sizeRequired)) {
|
||||
LOG.debug("Datanode {} is chosen. Required size is {}",
|
||||
node.toString(), sizeRequired);
|
||||
if (excludedNodes != null && excludedNodesForCapacity != null) {
|
||||
excludedNodes.removeAll(excludedNodesForCapacity);
|
||||
}
|
||||
return node;
|
||||
} else {
|
||||
maxRetry--;
|
||||
@ -275,6 +279,15 @@ private Node chooseNode(List<Node> excludedNodes, Node affinityNode,
|
||||
LOG.info(errMsg);
|
||||
throw new SCMException(errMsg, null);
|
||||
}
|
||||
if (excludedNodesForCapacity == null) {
|
||||
excludedNodesForCapacity = new ArrayList<>();
|
||||
}
|
||||
excludedNodesForCapacity.add(node);
|
||||
if (excludedNodes == null) {
|
||||
excludedNodes = excludedNodesForCapacity;
|
||||
} else {
|
||||
excludedNodes.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user