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


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -584,29 +583,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();
           Long scmContainerID = scmContainerInfo == null ? null : 
scmContainerInfo.getContainerID();
           if (omContainerID.equals(scmContainerID)) {
-            containerMetadata = omContainers.hasNext() ? omContainers.next() : 
null;
+            omContainers.seek(omContainerID + 1);
             scmContainerInfo = scmNonDeletedContainers.hasNext() ? 
scmNonDeletedContainers.next() : null;
           } else if (scmContainerID == null || 
omContainerID.compareTo(scmContainerID) < 0) {
-            notSCMContainers.add(containerMetadata);
-            containerMetadata = omContainers.hasNext() ? omContainers.next() : 
null;
+            ContainerMetadata omContainer = omContainers.next();
+            if (omContainer.getNumberOfKeys() > 0) {

Review Comment:
   I am just adding number of keys here. ContainerKeyPrefix only keeps 
container, key and version right? So this would be total number of keys only.



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