hemantk-12 commented on code in PR #6226:
URL: https://github.com/apache/ozone/pull/6226#discussion_r1498388729
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/OmSnapshotUtils.java:
##########
@@ -128,7 +130,12 @@ public static void createHardLinks(Path dbPath) throws
IOException {
"Failed to create directory: " + parent.toString());
}
}
- Files.createLink(fullToPath, fullFromPath);
+
+ if (isSamePartition(fullFromPath.getParent(),
fullToPath.getParent())) {
+ Files.createLink(fullToPath, fullFromPath);
+ } else {
+ Files.copy(fullFromPath, fullToPath,
StandardCopyOption.REPLACE_EXISTING);
+ }
Review Comment:
nit:
1. this code can be moved to helper function and reuse here and in line
193-196.
2. Should we change `createHardLinks` function name as well? Since it is
just not creating hard links.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/OmSnapshotUtils.java:
##########
@@ -137,13 +144,28 @@ public static void createHardLinks(Path dbPath) throws
IOException {
}
}
+ private static boolean isSamePartition(Path fromPathParent, Path
toPathParent) throws IOException {
+ try {
+ if (fromPathParent == null || toPathParent == null) {
Review Comment:
+1. You can also use `Objects.requireNonNull(fromPathParent, "From path is
null.")` and same for `toPathParent`.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/OmSnapshotUtils.java:
##########
@@ -137,13 +144,28 @@ public static void createHardLinks(Path dbPath) throws
IOException {
}
}
+ private static boolean isSamePartition(Path fromPathParent, Path
toPathParent) throws IOException {
+ try {
+ if (fromPathParent == null || toPathParent == null) {
+ throw new IOException("From path: " + fromPathParent + " or To path: "
+ toPathParent + " is null");
+ }
+
+ FileStore fromPathStore = Files.getFileStore(fromPathParent);
+ FileStore toPathStore = Files.getFileStore(toPathParent);
+ return fromPathStore.equals(toPathStore);
+ } catch (IOException ex) {
+ throw new IOException("Failed to get the stores, fromPath: " +
fromPathParent + " toPath: " + toPathParent, ex);
+ }
Review Comment:
No need to catch and throw the IOException when you have it in the method
signature. It is unnecessary wrapping.
--
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]