swamirishi commented on code in PR #8125:
URL: https://github.com/apache/ozone/pull/8125#discussion_r2020338583


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -584,29 +584,28 @@ public Response getContainerMisMatchInsights(
         new ArrayList<>();
     Long minContainerID = prevKey + 1;
     Iterator<ContainerInfo> scmNonDeletedContainers =
-            containerManager.getContainers().stream()
-                    .filter(containerInfo -> (containerInfo.getContainerID() 
>= minContainerID))
-                    .filter(containerInfo -> containerInfo.getState() != 
HddsProtos.LifeCycleState.DELETED)
-                    
.sorted(Comparator.comparingLong(ContainerInfo::getContainerID)).iterator();
-    ContainerInfo scmContainerInfo = scmNonDeletedContainers.hasNext() ?
-            scmNonDeletedContainers.next() : null;
+            
containerManager.getContainerInfoIterator(ContainerID.valueOf(minContainerID),
+              containerInfo -> containerInfo.getState() != 
HddsProtos.LifeCycleState.DELETED);
+    ContainerInfo scmContainerInfo = scmNonDeletedContainers.hasNext() ? 
scmNonDeletedContainers.next() : null;
     DataFilter dataFilter = DataFilter.fromValue(missingIn.toUpperCase());
     try (SeekableIterator<Long, ContainerMetadata> omContainers =
-                 reconContainerMetadataManager.getContainersIterator()) {
+           reconContainerMetadataManager.getContainersIterator()) {
       omContainers.seek(minContainerID);
-      ContainerMetadata containerMetadata = omContainers.hasNext() ? 
omContainers.next() : null;
+
       switch (dataFilter) {
       case SCM:
         List<ContainerMetadata> notSCMContainers = new ArrayList<>();
-        while (containerMetadata != null && notSCMContainers.size() < limit) {
-          Long omContainerID = containerMetadata.getContainerID();
+        while (omContainers.hasNext() && notSCMContainers.size() < limit) {
+          Long omContainerID = omContainers.peekNextKey();

Review Comment:
   This was intentional, there could be a lot of keys corresponding to a 
container. We don't have to go through the entire containerKeyPrefix entry if 
we don't have to send it as part of the response. We are right now using the 
containerKeyCount table instead and only deserializing the containerMetadata 
when we need it.



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