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


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -674,6 +675,40 @@ 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 table key corresponding to snapshot in 
snapshotInfoTable, this should be a value from cache
+   *                     and not from disk.
+   * @return True if the changes have been flushed to DB otherwise false
+   * @throws IOException
+   */
+  public static boolean areSnapshotChangesFlushedToDB(OMMetadataManager 
metadataManager, SnapshotInfo snapshotInfo)
+      throws IOException {
+    if (snapshotInfo != null) {
+      TransactionInfo snapshotTransactionInfo = 
snapshotInfo.getLastTransactionInfo() != null ?
+          
TransactionInfo.getCodec().fromPersistedFormat(snapshotInfo.getLastTransactionInfo().toByteArray())
 : null;

Review Comment:
   done



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -674,6 +675,40 @@ 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 table key corresponding to snapshot in 
snapshotInfoTable, this should be a value from cache
+   *                     and not from disk.
+   * @return True if the changes have been flushed to DB otherwise false
+   * @throws IOException
+   */
+  public static boolean areSnapshotChangesFlushedToDB(OMMetadataManager 
metadataManager, SnapshotInfo snapshotInfo)
+      throws IOException {
+    if (snapshotInfo != null) {

Review Comment:
   makes sense. 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]

Reply via email to