ashishkumar50 commented on code in PR #4724:
URL: https://github.com/apache/ozone/pull/4724#discussion_r1197424558


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -141,10 +140,18 @@ public Response getContainers(
       // Send back an empty response
       return Response.status(Response.Status.NOT_ACCEPTABLE).build();
     }
+    if (prevKey > 0) {
+      // Increase the limit by 1 to fetch one additional container
+      // since we are excluding the container with the same ID as prevKey
+      limit = limit + 1;

Review Comment:
   We can avoid increasing limit, as the getContainers() return results in 
sorted order, instead we can increase prevKey by 1 here as anyway we want to 
discard prevKey container info.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -141,10 +140,18 @@ public Response getContainers(
       // Send back an empty response
       return Response.status(Response.Status.NOT_ACCEPTABLE).build();
     }
+    if (prevKey > 0) {
+      // Increase the limit by 1 to fetch one additional container
+      // since we are excluding the container with the same ID as prevKey
+      limit = limit + 1;
+    }
+
     long containersCount;
-    Collection<ContainerMetadata> containerMetaDataList =
+    List<ContainerMetadata> containerMetaDataList =
         containerManager.getContainers(ContainerID.valueOf(prevKey), limit)
             .stream()
+            // Exclude the container with the same ID as prevKey
+            .filter(container -> container.getContainerID() != prevKey)

Review Comment:
   By increasing prevKey by one in the before step we don't need to do filter 
here as the results won't contain prevKey container info. And by doing this we 
get actual number of container information and not one extra container detail.



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