sodonnel commented on a change in pull request #881:
URL: https://github.com/apache/hadoop-ozone/pull/881#discussion_r418518747
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ReplicationManager.java
##########
@@ -582,17 +629,71 @@ private void handleOverReplicatedContainer(final
ContainerInfo container,
.filter(r -> !compareState(container.getState(), r.getState()))
.collect(Collectors.toList());
- //Move the unhealthy replicas to the front of eligible replicas to delete
- eligibleReplicas.removeAll(unhealthyReplicas);
- eligibleReplicas.addAll(0, unhealthyReplicas);
-
- for (int i = 0; i < excess; i++) {
- sendDeleteCommand(container,
- eligibleReplicas.get(i).getDatanodeDetails(), true);
+ // If there are unhealthy replicas, then we should remove them even if it
+ // makes the container violate the placement policy, as excess unhealthy
+ // containers are not really useful. It will be corrected later as a
+ // mis-replicated container will be seen as under-replicated.
+ for (ContainerReplica r : unhealthyReplicas) {
Review comment:
There could be more unhealthyReplicas than excess, and in that case, we
want to break if we have removed the excess count. The loop will always make at
least one pass.
I am not sure how we can use findAny() to make this cleaner, while also
decrementing excess.
Remember that it is possible to have an excess of, say 2, with one
unhealthy. So we would use the logic here to remove that unhealthy one
unconditionally. Then fall into the other logic to remove 1 more.
If you have a cleaner idea about how to do this please post a short code
snippet.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]