diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 025c761688f..2bdfcdf05b9 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -150,6 +150,8 @@ Release 2.8.0 - UNRELEASED HADOOP-12056. Use DirectoryStream in DiskChecker#checkDirs to detect errors when listing a directory. (Zhihai Xu via wang) + HADOOP-12055. Deprecate usage of NativeIO#link. (Andrew Wang via cnauroth) + OPTIMIZATIONS HADOOP-11785. Reduce the number of listStatus operation in distcp diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java index bc6e62ae402..688b955f6d8 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java @@ -881,6 +881,17 @@ public class NativeIO { } } + /** + * Creates a hardlink "dst" that points to "src". + * + * This is deprecated since JDK7 NIO can create hardlinks via the + * {@link java.nio.file.Files} API. + * + * @param src source file + * @param dst hardlink location + * @throws IOException + */ + @Deprecated public static void link(File src, File dst) throws IOException { if (!nativeLoaded) { HardLink.createHardLink(src, dst); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java index 089e0329caa..0bd08ddec6f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataStorage.java @@ -1044,7 +1044,7 @@ public class DataStorage extends Storage { idBasedLayoutSingleLinks.size()); for (int j = iCopy; j < upperBound; j++) { LinkArgs cur = idBasedLayoutSingleLinks.get(j); - NativeIO.link(cur.src, cur.dst); + HardLink.createHardLink(cur.src, cur.dst); } return null; }