From 0780fdb1ebdddd19744fbbca7fb05f8fe4bf4d28 Mon Sep 17 00:00:00 2001 From: Chris Douglas Date: Thu, 30 Nov 2017 15:13:16 -0800 Subject: [PATCH] HDFS-12877. Add open(PathHandle) with default buffersize --- .../java/org/apache/hadoop/fs/FileSystem.java | 15 +++++++++++++++ .../apache/hadoop/fs/TestFilterFileSystem.java | 1 + .../org/apache/hadoop/fs/TestHarFileSystem.java | 1 + 3 files changed, 17 insertions(+) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java index be0ec870602..a364921c2fe 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java @@ -951,6 +951,21 @@ public abstract class FileSystem extends Configured implements Closeable { IO_FILE_BUFFER_SIZE_DEFAULT)); } + /** + * Open an FSDataInputStream matching the PathHandle instance. The + * implementation may encode metadata in PathHandle to address the + * resource directly and verify that the resource referenced + * satisfies constraints specified at its construciton. + * @param fd PathHandle object returned by the FS authority. + * @throws IOException IO failure + * @throws UnsupportedOperationException If {@link #open(PathHandle, int)} + * not overridden by subclass + */ + public FSDataInputStream open(PathHandle fd) throws IOException { + return open(fd, getConf().getInt(IO_FILE_BUFFER_SIZE_KEY, + IO_FILE_BUFFER_SIZE_DEFAULT)); + } + /** * Open an FSDataInputStream matching the PathHandle instance. The * implementation may encode metadata in PathHandle to address the diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java index 4cbb8ab4045..0e9a6125f40 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java @@ -79,6 +79,7 @@ public class TestFilterFileSystem { public boolean mkdirs(Path f); public FSDataInputStream open(Path f); + public FSDataInputStream open(PathHandle f); public FSDataOutputStream create(Path f); public FSDataOutputStream create(Path f, boolean overwrite); public FSDataOutputStream create(Path f, Progressable progress); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java index a1aa4de2c0c..1b696938559 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java @@ -80,6 +80,7 @@ public class TestHarFileSystem { public boolean mkdirs(Path f); public FSDataInputStream open(Path f); + public FSDataInputStream open(PathHandle f); public FSDataOutputStream create(Path f); public FSDataOutputStream create(Path f, boolean overwrite); public FSDataOutputStream create(Path f, Progressable progress);