Package org.apache.hadoop.ozone.om
Class OmSnapshotManager
java.lang.Object
org.apache.hadoop.ozone.om.OmSnapshotManager
- All Implemented Interfaces:
AutoCloseable
This class is used to manage/create OM snapshots.
-
Field Summary
FieldsModifier and TypeFieldDescriptionFor snapshot compaction we need to capture SST files following column families before compaction.static final Stringstatic final Stringstatic final StringContains all the snap diff job which are either queued, in_progress or done.static final StringGlobal table to keep the diff report. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareSnapshotChangesFlushedToDB(org.apache.hadoop.ozone.om.OMMetadataManager metadataManager, String snapshotTableKey) Checks if the last transaction performed on the snapshot has been flushed to disk.static booleanareSnapshotChangesFlushedToDB(org.apache.hadoop.ozone.om.OMMetadataManager metadataManager, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo) Checks if the last transaction performed on the snapshot has been flushed to disk.org.apache.hadoop.ozone.snapshot.CancelSnapshotDiffResponsecancelSnapshotDiff(String volume, String bucket, String fromSnapshot, String toSnapshot) booleancanDisableFsSnapshot(org.apache.hadoop.ozone.om.OMMetadataManager ommm) Help reject OM startup if snapshot feature is disabled but there are snapshots remaining in this OM.voidclose()static org.apache.hadoop.hdds.utils.db.DBCheckpointcreateOmSnapshotCheckpoint(org.apache.hadoop.ozone.om.OMMetadataManager omMetadataManager, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo, org.apache.hadoop.hdds.utils.db.BatchOperation batchOperation) Creates snapshot checkpoint that corresponds to snapshotInfo.voidorg.apache.ratis.util.function.UncheckedAutoCloseableSupplier<org.apache.hadoop.ozone.om.IOmMetadataReader> getActiveFsMetadataOrSnapshot(String volumeName, String bucketName, String keyName) org.apache.ratis.util.function.UncheckedAutoCloseableSupplier<OmSnapshot> getActiveSnapshot(String volumeName, String bucketName, String snapshotName) longintintorg.apache.ratis.util.function.UncheckedAutoCloseableSupplier<OmSnapshot> getSnapshot(String volumeName, String bucketName, String snapshotName) org.apache.ratis.util.function.UncheckedAutoCloseableSupplier<OmSnapshot> getSnapshot(UUID snapshotId) Returns OmSnapshot object and skips active check.intGet snapshot instance LRU cache size.org.apache.hadoop.ozone.snapshot.ListSnapshotDiffJobResponsegetSnapshotDiffList(String volumeName, String bucketName, String jobStatus, boolean listAllStatus, String prevSnapshotDiffJob, int maxListResult) org.apache.hadoop.ozone.snapshot.SnapshotDiffResponsegetSnapshotDiffReport(String volume, String bucket, String fromSnapshot, String toSnapshot, String token, int pageSize, boolean forceFullDiff, boolean disableNativeDiff) static StringgetSnapshotPath(org.apache.hadoop.hdds.conf.OzoneConfiguration conf, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo) static PathgetSnapshotPath(org.apache.hadoop.ozone.om.OMMetadataManager omMetadataManager, UUID snapshotId) static PathgetSnapshotPath(org.apache.hadoop.ozone.om.OMMetadataManager omMetadataManager, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo) static StringgetSnapshotPrefix(String snapshotName) static List<org.rocksdb.LiveFileMetaData> getSnapshotSSTFileList(org.apache.hadoop.hdds.utils.db.RDBStore store) Captures the list of SST files for keyTable, fileTable and directoryTable in the DB.voidImmediately invalidate all entries and close their DB instances in cache.voidinvalidateCacheEntry(UUID key) Immediately invalidate an entry.static booleanisSnapshotFlushedToDB(org.apache.hadoop.ozone.om.OMMetadataManager metadataManager, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo) static booleanisSnapshotKey(String[] keyParts) voidvoid
-
Field Details
-
OM_HARDLINK_FILE
- See Also:
-
DELIMITER
- See Also:
-
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
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
For snapshot compaction we need to capture SST files following column families before compaction.
-
-
Constructor Details
-
OmSnapshotManager
- Throws:
IOException
-
-
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
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 managersnapshotInfo- The metadata of snapshot to be created- Returns:
- instance of DBCheckpoint
- Throws:
IOException
-
getSnapshotDiffManager
-
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
-
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
-
getSnapshotPath
public static Path getSnapshotPath(org.apache.hadoop.ozone.om.OMMetadataManager omMetadataManager, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo) -
getSnapshotPath
-
getSnapshotPath
public static String getSnapshotPath(org.apache.hadoop.hdds.conf.OzoneConfiguration conf, org.apache.hadoop.ozone.om.helpers.SnapshotInfo snapshotInfo) -
isSnapshotKey
-
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:
IOExceptionorg.apache.hadoop.ozone.om.exceptions.OMException
-
decrementInFlightSnapshotCount
public void decrementInFlightSnapshotCount() -
resetInFlightSnapshotCount
public void resetInFlightSnapshotCount() -
getInFlightSnapshotCount
public int getInFlightSnapshotCount() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getDiffCleanupServiceInterval
public long getDiffCleanupServiceInterval()
-