jojochuang commented on code in PR #8477:
URL: https://github.com/apache/ozone/pull/8477#discussion_r2157773429
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/OmSnapshotUtils.java:
##########
@@ -65,6 +66,12 @@ public static Object getINode(Path file) throws IOException {
return Files.readAttributes(file, BasicFileAttributes.class).fileKey();
}
+ public static String getInodeAndMtime(Path file) throws IOException {
Review Comment:
sugest a more descriptive method name. For instance,
`getFileInodeAndLastModifiedTimeString()`
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/OmSnapshotUtils.java:
##########
@@ -65,6 +66,12 @@ public static Object getINode(Path file) throws IOException {
return Files.readAttributes(file, BasicFileAttributes.class).fileKey();
}
+ public static String getInodeAndMtime(Path file) throws IOException {
Review Comment:
```suggestion
/**
* Returns a string combining the inode (fileKey) and the last modification
time (mtime) of the given file.
* <p>
* The returned string is formatted as "{inode}-{mtime}", where:
* <ul>
* <li>{@code inode} is the unique file key obtained from the file system,
typically representing the inode on POSIX systems</li>
* <li>{@code mtime} is the last modified time of the file in milliseconds
since the epoch</li>
* </ul>
*
* @param file the {@link Path} to the file whose inode and modification
time are to be retrieved
* @return a string in the format "{inode}-{mtime}"
* @throws IOException if an I/O error occurs
*/
public static String getInodeAndMtime(Path file) throws IOException {
```
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/Archiver.java:
##########
@@ -111,6 +114,34 @@ public static long includeFile(File file, String entryName,
return bytes;
}
+ /**
+ * Creates a hardlink for the given file in a temporary directory, adds it
+ * as an entry in the archive, and includes its contents in the archive
output.
+ * The temporary hardlink is deleted after processing.
+ */
Review Comment:
```suggestion
/**
* Creates a hard link to the specified file in the provided temporary
directory,
* adds the linked file as an entry to the archive with the given entry
name, writes
* its contents to the archive output, and then deletes the temporary hard
link.
* <p>
* This approach avoids altering the original file and works around
limitations
* of certain archiving libraries that may require the source file to be
present
* in a specific location or have a specific name. Any errors during the
hardlink
* creation or archiving process are logged.
* </p>
*
* @param file the file to be included in the archive
* @param entryName the name/path under which the file should appear in
the archive
* @param archiveOutput the output stream for the archive (e.g., tar)
* @param tmpDir the temporary directory in which to create the hard
link
* @return number of bytes copied to the archive for this file
* @throws IOException if an I/O error occurs other than hardlink creation
failure
*/
```
--
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]