nandakumar131 commented on code in PR #3885:
URL: https://github.com/apache/ozone/pull/3885#discussion_r1009761422
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -196,4 +203,40 @@ public static boolean isSnapshotKey(String[] keyParts) {
return (keyParts.length > 1) &&
(keyParts[0].compareTo(OM_SNAPSHOT_INDICATOR) == 0);
}
-}
+
+ public SnapshotDiffReport getSnapshotDiffReport(final String volume,
+ final String bucket,
+ final String fromSnapshot,
+ final String toSnapshot)
+ throws IOException {
+ // Validate fromSnapshot and toSnapshot
+ final SnapshotInfo fsInfo = getSnapshotInfo(volume, bucket, fromSnapshot);
+ final SnapshotInfo tsInfo = getSnapshotInfo(volume, bucket, toSnapshot);
+ verifySnapshotInfoForSnapDiff(fsInfo, tsInfo);
+
+ final String fsKey = SnapshotInfo.getTableKey(volume, bucket,
fromSnapshot);
+ final String tsKey = SnapshotInfo.getTableKey(volume, bucket, toSnapshot);
+ try {
+ final OmSnapshot fs = snapshotCache.get(fsKey);
+ final OmSnapshot ts = snapshotCache.get(tsKey);
+ return snapshotDiffManager.getSnapshotDiffReport(volume, bucket, fs, ts);
+ } catch (ExecutionException | RocksDBException e) {
+ throw new IOException(e.getCause());
+ }
+ }
+
+ private void verifySnapshotInfoForSnapDiff(final SnapshotInfo fromSnapshot,
+ final SnapshotInfo toSnapshot)
+ throws IOException {
+ if ((fromSnapshot.getSnapshotStatus() != SnapshotStatus.SNAPSHOT_ACTIVE) ||
+ (toSnapshot.getSnapshotStatus() != SnapshotStatus.SNAPSHOT_ACTIVE)) {
+ // TODO: throw custom snapshot exception.
+ throw new IOException("Cannot generate snapshot diff for non-active " +
+ "snapshots.");
+ }
+ if (fromSnapshot.getCreationTime() > toSnapshot.getCreationTime()) {
+ throw new IOException("fromSnapshot should be older than to toSnapshot");
Review Comment:
Done.
--
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]