hemantk-12 commented on code in PR #7179:
URL: https://github.com/apache/ozone/pull/7179#discussion_r1764252568


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -674,6 +675,41 @@ private ReferenceCounted<OmSnapshot> getSnapshot(String 
snapshotTableKey, boolea
     return snapshotCache.get(snapshotInfo.getSnapshotId());
   }
 
+  /**
+   * Checks if the last transaction performed on the snapshot has been flushed 
to disk.
+   * @param metadataManager Metadatamanager of Active OM.
+   * @param snapshotTableKey table key corresponding to snapshot in 
snapshotInfoTable.
+   * @return True if the changes have been flushed to DB otherwise false
+   * @throws IOException
+   */
+  public static boolean areSnapshotChangesFlushedToDB(OMMetadataManager 
metadataManager, String snapshotTableKey)
+      throws IOException {
+    // Need this info from cache since the snapshot could have been updated 
only on cache and not on disk.
+    SnapshotInfo snapshotInfo = 
metadataManager.getSnapshotInfoTable().get(snapshotTableKey);

Review Comment:
   nit: we should use 
[SnapshotUtils#getSnapshotInfo](https://github.com/apache/ozone/blob/master/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotUtils.java#L70).



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -674,6 +675,41 @@ private ReferenceCounted<OmSnapshot> getSnapshot(String 
snapshotTableKey, boolea
     return snapshotCache.get(snapshotInfo.getSnapshotId());
   }
 
+  /**
+   * Checks if the last transaction performed on the snapshot has been flushed 
to disk.
+   * @param metadataManager Metadatamanager of Active OM.
+   * @param snapshotTableKey table key corresponding to snapshot in 
snapshotInfoTable.
+   * @return True if the changes have been flushed to DB otherwise false
+   * @throws IOException
+   */
+  public static boolean areSnapshotChangesFlushedToDB(OMMetadataManager 
metadataManager, String snapshotTableKey)
+      throws IOException {
+    // Need this info from cache since the snapshot could have been updated 
only on cache and not on disk.
+    SnapshotInfo snapshotInfo = 
metadataManager.getSnapshotInfoTable().get(snapshotTableKey);
+    return areSnapshotChangesFlushedToDB(metadataManager, snapshotInfo);
+  }
+
+  /**
+   * Checks if the last transaction performed on the snapshot has been flushed 
to disk.
+   * @param metadataManager Metadatamanager of Active OM.
+   * @param snapshotInfo SnapshotInfo value.
+   * @return True if the changes have been flushed to DB otherwise false. It 
would return true if the snapshot
+   * provided is null meaning the snapshot doesn't exist.
+   * @throws IOException
+   */
+  public static boolean areSnapshotChangesFlushedToDB(OMMetadataManager 
metadataManager, SnapshotInfo snapshotInfo)

Review Comment:
   Looking at the usage of this function in 
[PR#7200](https://github.com/apache/ozone/pull/7200/files#diff-55b3048706799272e9f4c51bd618ea71687c5cf6570c4185dc657fbbdf5343fbR307),
 these static functions should be moved to SnapshotUtils.



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