Class OmSnapshotManager

java.lang.Object
org.apache.hadoop.ozone.om.OmSnapshotManager
All Implemented Interfaces:
AutoCloseable

public final class OmSnapshotManager extends Object implements AutoCloseable
This class is used to manage/create OM snapshots.
  • Field Details

    • DELIMITER

      public static final String DELIMITER
      See Also:
    • SNAP_DIFF_JOB_TABLE_NAME

      public static final String SNAP_DIFF_JOB_TABLE_NAME
      Contains all the snap diff job which are either queued, in_progress or done. This table is used to make sure that there is only single job for requests with the same snapshot pair at any point of time. |------------------------------------------------| | KEY | VALUE | |------------------------------------------------| | fromSnapshotId-toSnapshotId | SnapshotDiffJob | |------------------------------------------------|
      See Also:
    • SNAP_DIFF_REPORT_TABLE_NAME

      public static final String SNAP_DIFF_REPORT_TABLE_NAME
      Global table to keep the diff report. Each key is prefixed by the jobId to improve look up and clean up. JobId comes from snap-diff-job-table. |--------------------------------| | KEY | VALUE | |--------------------------------| | jobId-index | DiffReportEntry | |--------------------------------|
      See Also:
    • COLUMN_FAMILIES_TO_TRACK_IN_SNAPSHOT

      public static final Set<String> COLUMN_FAMILIES_TO_TRACK_IN_SNAPSHOT
      For snapshot compaction we need to capture SST files following column families before compaction.
  • Constructor Details

  • Method Details

    • canDisableFsSnapshot

      public boolean canDisableFsSnapshot(org.apache.hadoop.ozone.om.OMMetadataManager ommm)
      Help reject OM startup if snapshot feature is disabled but there are snapshots remaining in this OM. Note: snapshots that are already deleted but not cleaned up yet still counts.
      Parameters:
      ommm - OMMetadataManager
      Returns:
      true if SnapshotInfoTable is empty, false otherwise.
    • getMaxPageSize

      public int getMaxPageSize()
    • getSnapshotCacheSize

      public int getSnapshotCacheSize()
      Get snapshot instance LRU cache size.
      Returns:
      cache size.
    • invalidateCache

      public void invalidateCache()
      Immediately invalidate all entries and close their DB instances in cache.
    • invalidateCacheEntry

      public void invalidateCacheEntry(UUID key)
      Immediately invalidate an entry.
      Parameters:
      key - SnapshotId.
    • createOmSnapshotCheckpoint

      public static org.apache.hadoop.hdds.utils.db.DBCheckpoint createOmSnapshotCheckpoint(org.apache.hadoop.ozone.om.OMMetadataManager omMetadataManager, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo, org.apache.hadoop.hdds.utils.db.BatchOperation batchOperation) throws IOException
      Creates snapshot checkpoint that corresponds to snapshotInfo.
      Parameters:
      omMetadataManager - the metadata manager
      snapshotInfo - The metadata of snapshot to be created
      Returns:
      instance of DBCheckpoint
      Throws:
      IOException
    • getSnapshotDiffManager

      public SnapshotDiffManager getSnapshotDiffManager()
    • getSnapshotDiffCleanupService

      public SnapshotDiffCleanupService getSnapshotDiffCleanupService()
    • getSnapshotSSTFileList

      public static List<org.rocksdb.LiveFileMetaData> getSnapshotSSTFileList(org.apache.hadoop.hdds.utils.db.RDBStore store) throws IOException
      Captures the list of SST files for keyTable, fileTable and directoryTable in the DB.
      Parameters:
      store - AOS or snapshot DB for not defragged or defragged snapshot respectively.
      Returns:
      a Map of (table, set of SST files corresponding to the table)
      Throws:
      IOException
    • getActiveFsMetadataOrSnapshot

      public org.apache.ratis.util.function.UncheckedAutoCloseableSupplier<org.apache.hadoop.ozone.om.IOmMetadataReader> getActiveFsMetadataOrSnapshot(String volumeName, String bucketName, String keyName) throws IOException
      Throws:
      IOException
    • getActiveSnapshot

      public org.apache.ratis.util.function.UncheckedAutoCloseableSupplier<OmSnapshot> getActiveSnapshot(String volumeName, String bucketName, String snapshotName) throws IOException
      Throws:
      IOException
    • getSnapshot

      public org.apache.ratis.util.function.UncheckedAutoCloseableSupplier<OmSnapshot> getSnapshot(String volumeName, String bucketName, String snapshotName) throws IOException
      Throws:
      IOException
    • getSnapshotLocalDataManager

      public OmSnapshotLocalDataManager getSnapshotLocalDataManager()
    • areSnapshotChangesFlushedToDB

      public static boolean areSnapshotChangesFlushedToDB(org.apache.hadoop.ozone.om.OMMetadataManager metadataManager, String snapshotTableKey) throws IOException
      Checks if the last transaction performed on the snapshot has been flushed to disk.
      Parameters:
      metadataManager - Metadatamanager of Active OM.
      snapshotTableKey - table key corresponding to snapshot in snapshotInfoTable.
      Returns:
      True if the changes have been flushed to DB otherwise false
      Throws:
      IOException
    • areSnapshotChangesFlushedToDB

      public static boolean areSnapshotChangesFlushedToDB(org.apache.hadoop.ozone.om.OMMetadataManager metadataManager, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo) throws IOException
      Checks if the last transaction performed on the snapshot has been flushed to disk.
      Parameters:
      metadataManager - Metadatamanager of Active OM.
      snapshotInfo - SnapshotInfo value.
      Returns:
      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
    • isSnapshotFlushedToDB

      public static boolean isSnapshotFlushedToDB(org.apache.hadoop.ozone.om.OMMetadataManager metadataManager, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo) throws IOException
      Throws:
      IOException
    • getSnapshot

      public org.apache.ratis.util.function.UncheckedAutoCloseableSupplier<OmSnapshot> getSnapshot(UUID snapshotId) throws IOException
      Returns OmSnapshot object and skips active check. This should only be used for API calls initiated by background service e.g. purgeKeys, purgeSnapshot, snapshotMoveDeletedKeys, and SetSnapshotProperty.
      Throws:
      IOException
    • getSnapshotPrefix

      public static String getSnapshotPrefix(String snapshotName)
    • getSnapshotPath

      public static Path getSnapshotPath(org.apache.hadoop.ozone.om.OMMetadataManager omMetadataManager, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo)
    • getSnapshotPath

      public static Path getSnapshotPath(org.apache.hadoop.ozone.om.OMMetadataManager omMetadataManager, UUID snapshotId)
    • getSnapshotPath

      public static String getSnapshotPath(org.apache.hadoop.hdds.conf.OzoneConfiguration conf, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo)
    • isSnapshotKey

      public static boolean isSnapshotKey(String[] keyParts)
    • cancelSnapshotDiff

      public org.apache.hadoop.ozone.snapshot.CancelSnapshotDiffResponse cancelSnapshotDiff(String volume, String bucket, String fromSnapshot, String toSnapshot) throws IOException
      Throws:
      IOException
    • getSnapshotDiffReport

      public org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse getSnapshotDiffReport(String volume, String bucket, String fromSnapshot, String toSnapshot, String token, int pageSize, boolean forceFullDiff, boolean disableNativeDiff) throws IOException
      Throws:
      IOException
    • getSnapshotDiffList

      public org.apache.hadoop.ozone.snapshot.ListSnapshotDiffJobResponse getSnapshotDiffList(String volumeName, String bucketName, String jobStatus, boolean listAllStatus, String prevSnapshotDiffJob, int maxListResult) throws IOException
      Throws:
      IOException
    • snapshotLimitCheck

      public void snapshotLimitCheck() throws IOException, org.apache.hadoop.ozone.om.exceptions.OMException
      Throws:
      IOException
      org.apache.hadoop.ozone.om.exceptions.OMException
    • decrementInFlightSnapshotCount

      public void decrementInFlightSnapshotCount()
    • resetInFlightSnapshotCount

      public void resetInFlightSnapshotCount()
    • getInFlightSnapshotCount

      public int getInFlightSnapshotCount()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getDiffCleanupServiceInterval

      public long getDiffCleanupServiceInterval()