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


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/OmSnapshotLocalDataManager.java:
##########
@@ -95,14 +123,102 @@ public void createNewOmSnapshotLocalDataFile(RDBStore 
snapshotStore, SnapshotInf
   }
 
   public OmSnapshotLocalData getOmSnapshotLocalData(SnapshotInfo snapshotInfo) 
throws IOException {
-    Path snapshotLocalDataPath = 
Paths.get(getSnapshotLocalPropertyYamlPath(snapshotInfo));
-    return snapshotLocalDataSerializer.load(snapshotLocalDataPath.toFile());
+    return getOmSnapshotLocalData(snapshotInfo.getSnapshotId());
+  }
+
+  public OmSnapshotLocalData getOmSnapshotLocalData(UUID snapshotId) throws 
IOException {
+    Path snapshotLocalDataPath = 
Paths.get(getSnapshotLocalPropertyYamlPath(snapshotId));
+    OmSnapshotLocalData snapshotLocalData = 
snapshotLocalDataSerializer.load(snapshotLocalDataPath.toFile());
+    if (!Objects.equals(snapshotLocalData.getSnapshotId(), snapshotId)) {
+      throw new IOException("SnapshotId in path : " + snapshotLocalDataPath + 
" contains snapshotLocalData " +
+          "corresponding to snapshotId " + snapshotLocalData.getSnapshotId() + 
". Expected snapshotId " + snapshotId);
+    }
+    return snapshotLocalData;
   }
 
   public OmSnapshotLocalData getOmSnapshotLocalData(File snapshotDataPath) 
throws IOException {
     return snapshotLocalDataSerializer.load(snapshotDataPath);
   }
 
+  private LocalDataVersionNode getVersionNode(UUID snapshotId, int version) {
+    if (!versionNodeMap.containsKey(snapshotId)) {
+      return null;
+    }
+    return versionNodeMap.get(snapshotId).getVersionNode(version);
+  }
+
+  private boolean addSnapshotVersionMeta(UUID snapshotId, SnapshotVersionsMeta 
snapshotVersionsMeta)
+      throws IOException {
+    if (!versionNodeMap.containsKey(snapshotId)) {
+      for (LocalDataVersionNode versionNode : 
snapshotVersionsMeta.getSnapshotVersions().values()) {
+        if (getVersionNode(versionNode.snapshotId, versionNode.version) != 
null) {
+          throw new IOException("Unable to add " + versionNode + " since it 
already exists");
+        }
+        LocalDataVersionNode previousVersionNode = 
versionNode.previousSnapshotId == null ? null :
+            getVersionNode(versionNode.previousSnapshotId, 
versionNode.previousSnapshotVersion);
+        if (versionNode.previousSnapshotId != null && previousVersionNode == 
null) {
+          throw new IOException("Unable to add " + versionNode + " since 
previous snapshot with version hasn't been " +
+              "loaded");
+        }
+        localDataGraph.addNode(versionNode);

Review Comment:
   yeah the PR following this would use this graph



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