Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ private Set<String> getFiles(Path path, int truncateLength)
return getFiles(path, truncateLength, new HashSet<>());
}

// Get all files below path, recursively, (skipping fabricated files).
// Get all files below path, recursively, (skipping fabricated files, archive directory in rocksdb).
private Set<String> getFiles(Path path, int truncateLength,
Set<String> fileSet) throws IOException {
try (Stream<Path> files = Files.list(path)) {
Expand All @@ -754,8 +754,11 @@ private Set<String> getFiles(Path path, int truncateLength,
getFiles(file, truncateLength, fileSet);
}
String filename = String.valueOf(file.getFileName());
Path parentDir = file.getParent();
String parentFileName = parentDir == null ? "" : parentDir.getFileName().toString();
if (!filename.startsWith("fabricated") &&
!filename.startsWith(OZONE_RATIS_SNAPSHOT_COMPLETE_FLAG_NAME)) {
!filename.startsWith(OZONE_RATIS_SNAPSHOT_COMPLETE_FLAG_NAME) &&
!(filename.equals("archive") && parentFileName.startsWith("om.db"))) {
fileSet.add(truncateFileName(truncateLength, file));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,12 @@ public static DBCheckpoint createOmSnapshotCheckpoint(
}
OmSnapshotManager omSnapshotManager =
((OmMetadataManagerImpl) omMetadataManager).getOzoneManager().getOmSnapshotManager();
// Create the snapshot local property file.
OmSnapshotManager.createNewOmSnapshotLocalDataFile(omSnapshotManager, omMetadataManager, snapshotInfo, store);
try (UncheckedAutoCloseableSupplier<OmSnapshot> omSnapshotSupplier =
omSnapshotManager.getSnapshot(snapshotInfo.getSnapshotId())) {
// Create the snapshot local property file.
OmSnapshotManager.createNewOmSnapshotLocalDataFile(omSnapshotManager,
(RDBStore) omSnapshotSupplier.get().getMetadataManager().getStore(), snapshotInfo);
}

// Clean up active DB's deletedTable right after checkpoint is taken,
// Snapshot create is processed as a single transaction and
Expand Down Expand Up @@ -632,16 +636,15 @@ private static List<LiveFileMetaData> getSnapshotSSTFileList(RDBStore store)

/**
* Creates and writes snapshot local properties to a YAML file with uncompacted SST file list.
Comment thread
smengcl marked this conversation as resolved.
* @param omMetadataManager the metadata manager
* @param snapshotInfo The metadata of snapshot to be created
* @param store The store used to get uncompacted SST file list from.
* @param snapshotManager snapshot manager instance.
* @param snapshotStore snapshot metadata manager.
* @param snapshotInfo snapshot info instance corresponding to snapshot.
*/
public static void createNewOmSnapshotLocalDataFile(OmSnapshotManager snapshotManager,
OMMetadataManager omMetadataManager, SnapshotInfo snapshotInfo, RDBStore store)
throws IOException {
Path snapshotLocalDataPath = Paths.get(getSnapshotLocalPropertyYamlPath(omMetadataManager, snapshotInfo));
public static void createNewOmSnapshotLocalDataFile(OmSnapshotManager snapshotManager, RDBStore snapshotStore,
SnapshotInfo snapshotInfo) throws IOException {
Path snapshotLocalDataPath = Paths.get(getSnapshotLocalPropertyYamlPath(snapshotStore.getDbLocation().toPath()));

Copilot AI Aug 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method signature changed to accept snapshotStore.getDbLocation().toPath() but getSnapshotLocalPropertyYamlPath likely expects different parameters. This may cause a compilation error or runtime failure.

Suggested change
Path snapshotLocalDataPath = Paths.get(getSnapshotLocalPropertyYamlPath(snapshotStore.getDbLocation().toPath()));
Path snapshotLocalDataPath = getSnapshotLocalPropertyYamlPath(snapshotStore.getDbLocation().toPath());

Copilot uses AI. Check for mistakes.
Files.deleteIfExists(snapshotLocalDataPath);
OmSnapshotLocalDataYaml snapshotLocalDataYaml = new OmSnapshotLocalDataYaml(getSnapshotSSTFileList(store),
OmSnapshotLocalDataYaml snapshotLocalDataYaml = new OmSnapshotLocalDataYaml(getSnapshotSSTFileList(snapshotStore),
snapshotInfo.getPathPreviousSnapshotId());
snapshotLocalDataYaml.writeToYaml(snapshotManager, snapshotLocalDataPath.toFile());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static org.apache.hadoop.ozone.OzoneConsts.SNAPSHOT_INFO_TABLE;
import static org.apache.hadoop.ozone.om.OMDBCheckpointServlet.processFile;
import static org.apache.hadoop.ozone.om.OmSnapshotManager.OM_HARDLINK_FILE;
import static org.apache.hadoop.ozone.om.OmSnapshotManager.getSnapshotPath;
import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.BUCKET_TABLE;
import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.DIRECTORY_TABLE;
import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.FILE_TABLE;
Expand Down Expand Up @@ -311,12 +312,12 @@ public void testCreateNewSnapshotLocalYaml() throws IOException {

Path snapshotYaml = Paths.get(OmSnapshotManager.getSnapshotLocalPropertyYamlPath(
omMetadataManager, snapshotInfo));

when(mockedStore.getDbLocation()).thenReturn(getSnapshotPath(omMetadataManager, snapshotInfo).toFile());
// Create an existing YAML file for the snapshot
assertTrue(snapshotYaml.toFile().createNewFile());
assertEquals(0, Files.size(snapshotYaml));
// Create a new YAML file for the snapshot
OmSnapshotManager.createNewOmSnapshotLocalDataFile(omSnapshotManager, omMetadataManager, snapshotInfo, mockedStore);
OmSnapshotManager.createNewOmSnapshotLocalDataFile(omSnapshotManager, mockedStore, snapshotInfo);
// Verify that previous file was overwritten
assertTrue(Files.exists(snapshotYaml));
assertTrue(Files.size(snapshotYaml) > 0);
Expand Down
Loading