sumitagrawl commented on code in PR #9472:
URL: https://github.com/apache/ozone/pull/9472#discussion_r2621913754


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManagerImpl.java:
##########
@@ -173,6 +175,46 @@ public int getContainerStateCount(final LifeCycleState 
state) {
     return containerStateManager.getContainerCount(state);
   }
 
+  @Override
+  public List<ContainerInfo> getContainersByHealthState(
+      HealthStateFilter filter) {
+    scmContainerManagerMetrics.incNumListContainersOps();
+    List<ContainerInfo> result = new ArrayList<>();
+
+    // Iterate through all containers using a large count
+    List<ContainerInfo> allContainers =
+        containerStateManager.getContainerInfos(ContainerID.MIN, 
Integer.MAX_VALUE);
+
+    for (ContainerInfo containerInfo : allContainers) {
+      if (containerInfo.getHealthState() != null &&
+          filter.matches(containerInfo.getHealthState())) {
+        result.add(containerInfo);
+      }
+    }
+
+    return result;
+  }
+
+  @Override
+  public Map<ContainerInfo, ContainerHealthState> getContainersWithHealthState(

Review Comment:
   we can remove unused methods, can be implemented with optimized way



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationManager.java:
##########
@@ -878,7 +879,15 @@ protected boolean processContainer(ContainerInfo 
containerInfo,
       if (!handled) {

Review Comment:
   We can set state inside Report about container, initially healthy. And once 
finished, overwrite the actual state at below logic



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/health/ClosedWithUnhealthyReplicasHandler.java:
##########
@@ -109,9 +109,9 @@ public boolean handle(ContainerCheckRequest request) {
     // some unhealthy replicas were found so the container must be
     // over replicated due to unhealthy replicas.
     if (foundUnhealthy) {
-      request.getReport().incrementAndSample(
-          ReplicationManagerReport.HealthState.OVER_REPLICATED,
-          containerInfo.containerID());
+      ContainerHealthState healthState = ContainerHealthState.OVER_REPLICATED;
+      request.getReport().incrementAndSample(healthState, 
containerInfo.containerID());
+      containerInfo.setHealthState(healthState);

Review Comment:
   move this inside incrementAndSample()



-- 
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]

Reply via email to