devmadhuu commented on code in PR #9258:
URL: https://github.com/apache/ozone/pull/9258#discussion_r2828912966


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -451,6 +482,81 @@ public Response getUnhealthyContainers(
     return Response.ok(response).build();
   }
 
+  /**
+   * V2 implementation - reads from UNHEALTHY_CONTAINERS_V2 table.
+   */
+  private Response getUnhealthyContainersV2(
+      String state,
+      int limit,
+      long maxContainerId,
+      long minContainerId) {
+    List<UnhealthyContainerMetadata> unhealthyMeta = new ArrayList<>();
+    List<UnhealthyContainersSummary> summary = new ArrayList<>();
+
+    try {
+      ContainerSchemaDefinitionV2.UnHealthyContainerStates v2State = null;
+
+      if (state != null) {
+        // Convert V1 state string to V2 enum
+        v2State = 
ContainerSchemaDefinitionV2.UnHealthyContainerStates.valueOf(state);
+      }
+
+      // Get summary from V2 table and convert to V1 format
+      List<ContainerHealthSchemaManagerV2.UnhealthyContainersSummaryV2> 
v2Summary =
+          containerHealthSchemaManagerV2.getUnhealthyContainersSummary();
+      for (ContainerHealthSchemaManagerV2.UnhealthyContainersSummaryV2 s : 
v2Summary) {
+        summary.add(new UnhealthyContainersSummary(s.getContainerState(), 
s.getCount()));
+      }
+
+      // Get containers from V2 table
+      List<ContainerHealthSchemaManagerV2.UnhealthyContainerRecordV2> 
v2Containers =
+          containerHealthSchemaManagerV2.getUnhealthyContainers(v2State, 
minContainerId, maxContainerId, limit);
+
+      // Convert V2 records to response format
+      for (ContainerHealthSchemaManagerV2.UnhealthyContainerRecordV2 c : 
v2Containers) {
+        long containerID = c.getContainerId();
+        ContainerInfo containerInfo =
+            containerManager.getContainer(ContainerID.valueOf(containerID));
+        long keyCount = containerInfo.getNumberOfKeys();
+        UUID pipelineID = containerInfo.getPipelineID().getId();
+        List<ContainerHistory> datanodes =
+            containerManager.getLatestContainerHistory(containerID,
+                containerInfo.getReplicationConfig().getRequiredNodes());
+
+        // Create UnhealthyContainers POJO from V2 record for response
+        UnhealthyContainers v1Container = new UnhealthyContainers();

Review Comment:
   removed and added shorter version



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