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


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -1180,6 +1199,37 @@ Set<String> getDeltaFiles(OmSnapshot fromSnapshot,
     // TODO: [SNAPSHOT] Refactor the parameter list
     Optional<Set<String>> deltaFiles = Optional.empty();
 
+    OmSnapshotLocalData fromSnapshotLocalData = getSnapshotLocalData(fsInfo);
+    int fromSnapshotVersion = fromSnapshotLocalData.getVersion();
+    OmSnapshotLocalData toSnapshotLocalData = getSnapshotLocalData(tsInfo);
+    int toSnapshotVersion = toSnapshotLocalData.getVersion();
+
+    try {
+      if (fromSnapshotVersion > 0 && toSnapshotVersion > 0) {
+        // both snapshots are defragmented, To calculate snap-diff, we can 
simply compare the
+        // SST files contained in OmSnapshotLocalData instances of both these 
and get the delta files
+        OmSnapshotLocalData.VersionMeta toSnapVersionMeta =
+            
toSnapshotLocalData.getVersionSstFileInfos().get(toSnapshotVersion);
+        // get the source snapshot SST files (versionMeta)  corresponding to 
target snapshot
+        OmSnapshotLocalData.VersionMeta fromSnapVersionMeta =
+            resolveBaseVersionMeta(toSnapshotLocalData, 
fromSnapshot.getSnapshotID());
+        // Calculate diff files using helper method
+        if (toSnapVersionMeta == null) {
+          String errMsg =
+              "Cannot find corresponding version of from snapshot " + 
fromSnapshotVersion + " from " + tsInfo;
+          LOG.error(errMsg);
+          throw new IOException(errMsg);
+        }
+        List<String> diffFiles = calculateDiffFiles(fromSnapVersionMeta, 
toSnapVersionMeta);
+        return OmSnapshotUtils.getSSTDiffListWithFullPath(diffFiles,
+            
OmSnapshotManager.getSnapshotPath(ozoneManager.getMetadataManager(), 
fsInfo).toString(),
+            
OmSnapshotManager.getSnapshotPath(ozoneManager.getMetadataManager(), 
tsInfo).toString(), diffDir);
+      }
+    } catch (Exception e) {
+      LOG.error("Failed to calculate snap-diff between fromSnapshot : {} , 
toSnapshot: {} via optimal method," +
+          "Falling back to other methods", fsInfo, tsInfo, e);
+    }
+
     // Check if compaction DAG is available, use that if so
     if (differ != null && fsInfo != null && tsInfo != null && !useFullDiff) {

Review Comment:
   We need rocksdb checkpoint differ to also use the SnapshotLocalMetadata 
instead of the rocksdb instance itself.
   There are 3 possible conditions:
   
   1. fromSnapshot is defragged and toSNapshot Defragged
   2. fromSnapshot is not defragged and toSnapshot not defragged
   3. fromSnapshot is Defragged and toSnapshot not Defragged
   4. fromSnapshot is not Defragged and toSnapshot Defragged(This is not 
possible.)
   This patch covers only the first condition so far. 2 and 3 condition should 
fall back to dag based diff by using both version 0's sst files to compute diff.
   Effectively logic the logic for snapshot diff should be like this :
   ```
   if (toSnapshot.getVersion() > 0) {
      perfromFullDiff(fromSnapshot(version=correspoding version from traversing 
linked list), toSnapshot(version=toSnapshotVersion));
   } else {
    if (Dag available) {
         performDagDiff(fromSnapshot(version=0), toSnapshot(version=0));
   } else {
        peformFullDiff(fromSnapshot(version=0), toSnapshot(version=0))
   }
   }
   }
   
   ```



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