smengcl commented on code in PR #4360:
URL: https://github.com/apache/ozone/pull/4360#discussion_r1136481684


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -131,80 +171,124 @@ private DifferSnapshotInfo getDSIFromSI(SnapshotInfo 
snapshotInfo,
         getTablePrefixes(snapshotOMMM, volumeName, bucketName));
   }
 
-  @SuppressWarnings("checkstyle:methodlength")
+  @SuppressWarnings("parameternumber")
   public SnapshotDiffReport getSnapshotDiffReport(final String volume,
                                                   final String bucket,
                                                   final OmSnapshot 
fromSnapshot,
                                                   final OmSnapshot toSnapshot,
                                                   final SnapshotInfo fsInfo,
-                                                  final SnapshotInfo tsInfo)
+                                                  final SnapshotInfo tsInfo,
+                                                  final int index,
+                                                  final int pageSize)
       throws IOException, RocksDBException {
+    String diffJobKey = fsInfo.getSnapshotID() + DELIMITER +
+        tsInfo.getSnapshotID();
+
+    Pair<String, Boolean> jobIdToJobExist = getOrCreateJobId(diffJobKey);
+    String jobId = jobIdToJobExist.getLeft();
+    boolean jobExist = jobIdToJobExist.getRight();
+
+    // If snapshot diff doesn't exist, we generate the diff report first
+    // and add it to the table for future requests.
+    // This needs to be updated to queuing and job status base.
+    if (!jobExist) {
+      generateSnapshotDiffReport(jobId, volume, bucket, fromSnapshot,
+          toSnapshot, fsInfo, tsInfo);
+    }
 
-    final BucketLayout bucketLayout = getBucketLayout(volume, bucket,
-        fromSnapshot.getMetadataManager());
+    List<DiffReportEntry> diffReportList = new ArrayList<>();
 
-    // TODO: This should comes from request itself.
-    String requestId = UUID.randomUUID().toString();
+    boolean hasMoreEntries = true;
 
+    for (int idx = index; idx - index < pageSize; idx++) {
+      byte[] rawKey = codecRegistry.asRawData(jobId + DELIMITER + idx);
+      byte[] bytes = snapDiffReportTable.get(rawKey);
+      if (bytes == null) {
+        hasMoreEntries = false;
+        break;
+      }
+      diffReportList.add(codecRegistry.asObject(bytes, DiffReportEntry.class));
+    }
+
+    String tokenString = hasMoreEntries ?
+        String.valueOf(index + pageSize) : null;

Review Comment:
   UT sounds good to me



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