hemantk-12 commented on code in PR #6543:
URL: https://github.com/apache/ozone/pull/6543#discussion_r2008338228


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -423,30 +424,46 @@ public CancelSnapshotDiffResponse cancelSnapshotDiff(
     return new CancelSnapshotDiffResponse(reason);
   }
 
-  public List<SnapshotDiffJob> getSnapshotDiffJobList(
-      String volumeName, String bucketName,
-      String jobStatus, boolean listAll) throws IOException {
-    List<SnapshotDiffJob> jobList = new ArrayList<>();
+  public ListSnapshotDiffJobResponse getSnapshotDiffJobList(String volumeName,
+                                                            String bucketName,
+                                                            String jobStatus,
+                                                            boolean listAll,
+                                                            String prevDiffJob,
+                                                            int maxEntries) 
throws IOException {
+    List<SnapshotDiffJob> jobs = new ArrayList<>();
+    String lastSnapshotDiffJob = null;
 
     try (ClosableIterator<Map.Entry<String, SnapshotDiffJob>> iterator =
-             snapDiffJobTable.iterator()) {
+             snapDiffJobTable.iterator(Optional.ofNullable(prevDiffJob), 
Optional.empty())) {
+      Map.Entry<String, SnapshotDiffJob> entry = null;
       while (iterator.hasNext()) {
-        SnapshotDiffJob snapshotDiffJob = iterator.next().getValue();
+        entry = iterator.next();
+        SnapshotDiffJob snapshotDiffJob = entry.getValue();
+        if (Objects.equals(prevDiffJob, entry.getKey())) {
+          continue;
+        }
+
         if (Objects.equals(snapshotDiffJob.getVolume(), volumeName) &&
             Objects.equals(snapshotDiffJob.getBucket(), bucketName)) {
           if (listAll) {
-            jobList.add(snapshotDiffJob);
-            continue;
-          }
-
-          if (Objects.equals(snapshotDiffJob.getStatus(),
-              getJobStatus(jobStatus))) {
-            jobList.add(snapshotDiffJob);
+            jobs.add(snapshotDiffJob);
+          } else if (Objects.equals(snapshotDiffJob.getStatus(), 
getJobStatus(jobStatus))) {
+            jobs.add(snapshotDiffJob);
           }
         }
+        if (jobs.size() == maxEntries) {
+          break;
+        }
+      }
+
+      // If maxEntries are populated and list still has more entries,
+      // set the continuation token for the next page request otherwise null.
+      if (jobs.size() == maxEntries && iterator.hasNext()) {

Review Comment:
   Removed `job.size() == maxEntries` check in #8124



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