diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerSelectionCriteria.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerSelectionCriteria.java
index ec0e493c28f9..8171320a54f8 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerSelectionCriteria.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerSelectionCriteria.java
@@ -24,6 +24,7 @@
import org.apache.hadoop.hdds.scm.container.ContainerManager;
import org.apache.hadoop.hdds.scm.container.ContainerNotFoundException;
import org.apache.hadoop.hdds.scm.container.ContainerReplica;
+import org.apache.hadoop.hdds.scm.container.replication.LegacyReplicationManager;
import org.apache.hadoop.hdds.scm.container.replication.ReplicationManager;
import org.apache.hadoop.hdds.scm.node.NodeManager;
import org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException;
@@ -85,11 +86,7 @@ private boolean isContainerReplicatingOrDeleting(ContainerID containerID) {
* 3. Container size should be closer to 5GB.
* 4. Container must not be in the configured exclude containers list.
* 5. Container should be closed.
- * 6. Container should not be an EC container
- * //TODO Temporarily not considering EC containers as candidates
- * @see
- * HDDS-6940
- *
+ * 6. If the {@link LegacyReplicationManager} is enabled, then the container should not be an EC container.
* @param node DatanodeDetails for which to find candidate containers.
* @return NavigableSet of candidate containers that satisfy the criteria.
*/
@@ -158,12 +155,12 @@ private Comparator orderContainersByUsedBytes() {
/**
* Checks whether a Container has the ReplicationType
- * {@link HddsProtos.ReplicationType#EC}.
+ * {@link HddsProtos.ReplicationType#EC} and the Legacy Replication Manger is enabled.
* @param container container to check
* @return true if the ReplicationType is EC and "hdds.scm.replication
* .enable.legacy" is true, else false
*/
- private boolean isECContainer(ContainerInfo container) {
+ private boolean isECContainerAndLegacyRMEnabled(ContainerInfo container) {
return container.getReplicationType().equals(HddsProtos.ReplicationType.EC)
&& replicationManager.getConfig().isLegacyEnabled();
}
@@ -178,7 +175,7 @@ private boolean shouldBeExcluded(ContainerID containerID,
"candidate container. Excluding it.", containerID);
return true;
}
- return !isContainerClosed(container, node) || isECContainer(container) ||
+ return !isContainerClosed(container, node) || isECContainerAndLegacyRMEnabled(container) ||
isContainerReplicatingOrDeleting(containerID) ||
!findSourceStrategy.canSizeLeaveSource(node, container.getUsedBytes())
|| breaksMaxSizeToMoveLimit(container.containerID(),