GeorgeJahad commented on code in PR #3980:
URL: https://github.com/apache/ozone/pull/3980#discussion_r1130203539
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmSnapshotManager.java:
##########
@@ -279,6 +307,92 @@ private void verifySnapshotInfoForSnapDiff(final
SnapshotInfo fromSnapshot,
}
}
+ /**
+ * Create file of links to add to tarball.
+ * Format of entries are either:
+ * dir1/fileTo fileFrom
+ * for files in active db or:
+ * dir1/fileTo dir2/fileFrom
+ * for files in another directory, (either another snapshot dir or
+ * sst compaction backup directory)
+ * @param truncateLength - Length of initial path to trim in file path.
+ * @param hardLinkFiles - Map of link->file paths.
+ * @return Path to the file of links created.
+ */
+ @SuppressFBWarnings({"NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"})
+ static Path createHardLinkList(int truncateLength,
+ Map<Path, Path> hardLinkFiles)
+ throws IOException {
+ Path data = Files.createTempFile("data", "txt");
+ StringBuilder sb = new StringBuilder();
+ for (Map.Entry<Path, Path> entry : hardLinkFiles.entrySet()) {
+ String fixedFile = truncateFileName(truncateLength, entry.getValue());
+ // If this file is from the active db, strip the path.
+ if (fixedFile.startsWith(OM_CHECKPOINT_DIR)) {
+ fixedFile = Paths.get(fixedFile).getFileName().toString();
+ }
+ sb.append(truncateFileName(truncateLength, entry.getKey()))
+ .append("\t")
+ .append(fixedFile)
+ .append("\n");
+ }
+ Files.write(data, sb.toString().getBytes(StandardCharsets.UTF_8));
+ return data;
+ }
+
+ /**
+ * Get the filename without the introductory metadata directory.
+ *
+ * @param truncateLength Length to remove.
+ * @param file File to remove prefix from.
+ * @return Truncated string.
+ */
+ static String truncateFileName(int truncateLength, Path file) {
+ return file.toString().substring(truncateLength);
+ }
+
+ /**
+ * Create hard links listed in OM_HARDLINK_FILE.
+ *
+ * @param dbPath Path to db to have links created.
+ */
+ static void createHardLinks(Path dbPath) throws IOException {
Review Comment:
So there is a unit test here that excercises the details of those methods:
https://github.com/apache/ozone/blob/ed069f01142452dfc59b3f9703e486ef0434d7e4/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmSnapshotManager.java#L132
The integration test of which checks a follower bootstrapping existed
already already. I just modified it to add a test to confirm the snapshot data
was uploaded as well:
https://github.com/apache/ozone/blob/ed069f01142452dfc59b3f9703e486ef0434d7e4/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshots.java#L243-L252
Is that sufficient?
--
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]