greenwich commented on code in PR #12144:
URL: https://github.com/apache/ozone/pull/12144#discussion_r4675961192
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/SCMContainerPlacementRackScatter.java:
##########
@@ -333,9 +333,12 @@ protected List<DatanodeDetails> chooseDatanodesInternal(
}
if (chosenNodes.size() < nodesRequired) {
- racks.addAll(usedRacksCntMap.keySet());
+ // usedRacksCntMap iterates in the same order for the same racks, so
shuffle to spread extra replicas
+ List<Node> usedRacks = new ArrayList<>(usedRacksCntMap.keySet());
+ Collections.shuffle(usedRacks);
+ racks.addAll(usedRacks);
racks = sortRackWithExcludedNodes(racks, excludedNodes, usedRacksCntMap);
- racks.addAll(usedRacksCntMap.keySet());
+ racks.addAll(usedRacks);
Review Comment:
`sortRackWithExcludedNodes` keeps only racks that have no replica yet, so
the second `addAll` is what puts the already-used racks back in, after the
unused ones, for the fill pass. The first `addAll` has no effect because those
racks are dropped straight away, but it was already there on master, so I kept
it to keep the diff small.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]