sadanand48 commented on code in PR #9079:
URL: https://github.com/apache/ozone/pull/9079#discussion_r2409703845
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -1223,6 +1265,70 @@ Set<String> getDeltaFiles(OmSnapshot fromSnapshot,
toSnapshot.getSnapshotTableKey()));
}
+ /**
+ * Resolve the VersionMeta of the ancestor snapshot (fromSnapshotId)
+ * that the given snapshot (toSnapshot) was built on.
+ *
+ * Traverses the snapshot chain backwards using prevSnapId.
+ */
+ private OmSnapshotLocalData.VersionMeta resolveBaseVersionMeta(
+ OmSnapshotLocalData toSnapshot,
+ UUID fromSnapshotId) throws IOException {
+ OmMetadataManagerImpl metadataManager =
+ (OmMetadataManagerImpl) ozoneManager.getMetadataManager();
+ // Start walking back from the child snapshot
+ OmSnapshotLocalData child = toSnapshot;
+ while (!child.getPreviousSnapshotId().equals(fromSnapshotId)) {
+ UUID parentId = child.getPreviousSnapshotId();
+ // Load the parent snapshot in the chain
+ child = getSnapshotLocalData(
+ getSnapshotInfo(ozoneManager,
+ metadataManager.getSnapshotChainManager(),
+ parentId));
+ }
+ SnapshotInfo snapshotInfo =
+ getSnapshotInfo(ozoneManager,
metadataManager.getSnapshotChainManager(), fromSnapshotId);
+ OmSnapshotLocalData fromSnapshot = getSnapshotLocalData(snapshotInfo);
+ // Get the version that the child was built from
+ OmSnapshotLocalData.VersionMeta childVersionMeta =
child.getVersionSstFileInfos().get(child.getVersion());
+ int versionUsedWhenBuildingChild =
childVersionMeta.getPreviousSnapshotVersion();
+ return
fromSnapshot.getVersionSstFileInfos().get(versionUsedWhenBuildingChild);
Review Comment:
generally shouldn't happen. If it does, The method would return null in that
case and it would fall back to use other methods to find the diff
```java
if (toSnapVersionMeta == null) {
String errMsg =
"Cannot find corresponding version of from snapshot " +
fromSnapshotVersion + " from " + tsInfo;
LOG.error(errMsg);
throw new IOException(errMsg);
}
```
--
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]