[hadoop] 03/03: HADOOP-13055. Implement linkMergeSlash and linkFallback for ViewFileSystem
This is an automated email from the ASF dual-hosted git repository. omalley pushed a commit to branch branch-2.10 in repository https://gitbox.apache.org/repos/asf/hadoop.git commit ef8582bfa87c734f9251dd6d9ed57dd649646134 Author: Manoj Govindassamy AuthorDate: Fri Oct 13 17:43:13 2017 -0700 HADOOP-13055. Implement linkMergeSlash and linkFallback for ViewFileSystem (cherry picked from commit 133d7ca76e3d4b60292d57429d4259e80bec650a) Fixes #4015 --- .../org/apache/hadoop/fs/viewfs/ConfigUtil.java| 68 +++- .../org/apache/hadoop/fs/viewfs/Constants.java | 16 +- .../org/apache/hadoop/fs/viewfs/InodeTree.java | 351 ++--- .../apache/hadoop/fs/viewfs/ViewFileSystem.java| 13 +- .../java/org/apache/hadoop/fs/viewfs/ViewFs.java | 14 +- .../hadoop/fs/viewfs/ViewFileSystemBaseTest.java | 4 +- .../hadoop-hdfs/src/site/markdown/ViewFs.md| 44 ++- .../fs/viewfs/TestViewFileSystemLinkFallback.java | 264 .../viewfs/TestViewFileSystemLinkMergeSlash.java | 234 ++ 9 files changed, 940 insertions(+), 68 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java index 8acd41f..5867f62 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java @@ -18,6 +18,7 @@ package org.apache.hadoop.fs.viewfs; import java.net.URI; +import java.util.Arrays; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.StringUtils; @@ -68,7 +69,72 @@ public class ConfigUtil { addLink( conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, src, target); } - + + /** + * Add a LinkMergeSlash to the config for the specified mount table. + * @param conf + * @param mountTableName + * @param target + */ + public static void addLinkMergeSlash(Configuration conf, + final String mountTableName, final URI target) { +conf.set(getConfigViewFsPrefix(mountTableName) + "." + +Constants.CONFIG_VIEWFS_LINK_MERGE_SLASH, target.toString()); + } + + /** + * Add a LinkMergeSlash to the config for the default mount table. + * @param conf + * @param target + */ + public static void addLinkMergeSlash(Configuration conf, final URI target) { +addLinkMergeSlash(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, +target); + } + + /** + * Add a LinkFallback to the config for the specified mount table. + * @param conf + * @param mountTableName + * @param target + */ + public static void addLinkFallback(Configuration conf, + final String mountTableName, final URI target) { +conf.set(getConfigViewFsPrefix(mountTableName) + "." + +Constants.CONFIG_VIEWFS_LINK_FALLBACK, target.toString()); + } + + /** + * Add a LinkFallback to the config for the default mount table. + * @param conf + * @param target + */ + public static void addLinkFallback(Configuration conf, final URI target) { +addLinkFallback(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, +target); + } + + /** + * Add a LinkMerge to the config for the specified mount table. + * @param conf + * @param mountTableName + * @param targets + */ + public static void addLinkMerge(Configuration conf, + final String mountTableName, final URI[] targets) { +conf.set(getConfigViewFsPrefix(mountTableName) + "." + +Constants.CONFIG_VIEWFS_LINK_MERGE, Arrays.toString(targets)); + } + + /** + * Add a LinkMerge to the config for the default mount table. + * @param conf + * @param targets + */ + public static void addLinkMerge(Configuration conf, final URI[] targets) { +addLinkMerge(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, targets); + } + /** * * @param conf diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java index 3f9aae2..7a0a6661 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java @@ -51,12 +51,17 @@ public interface Constants { /** * Config variable for specifying a simple link */ - public static final String CONFIG_VIEWFS_LINK = "link"; - + String CONFIG_VIEWFS_LINK = "link"; + + /** + * Config variable for specifying a fallback for link mount points. + */ + String CONFIG_VIEWFS_LINK_FALLBACK = "linkFallback"; + /** * Config variable for specifying a merge link */ - public static final String CONFIG_VIEWFS_LINK_MERGE = "linkMerge"; + String CONFIG_VIEWFS_LINK_MERGE =
[hadoop] 03/03: HADOOP-13055. Implement linkMergeSlash and linkFallback for ViewFileSystem
This is an automated email from the ASF dual-hosted git repository. shv pushed a commit to branch HADOOP-18127 in repository https://gitbox.apache.org/repos/asf/hadoop.git commit 3682078fb872604576180610cc2fac67d04a8692 Author: Manoj Govindassamy AuthorDate: Fri Oct 13 17:43:13 2017 -0700 HADOOP-13055. Implement linkMergeSlash and linkFallback for ViewFileSystem (cherry picked from commit 133d7ca76e3d4b60292d57429d4259e80bec650a) --- .../org/apache/hadoop/fs/viewfs/ConfigUtil.java| 68 +++- .../org/apache/hadoop/fs/viewfs/Constants.java | 16 +- .../org/apache/hadoop/fs/viewfs/InodeTree.java | 351 ++--- .../apache/hadoop/fs/viewfs/ViewFileSystem.java| 13 +- .../java/org/apache/hadoop/fs/viewfs/ViewFs.java | 14 +- .../hadoop/fs/viewfs/ViewFileSystemBaseTest.java | 4 +- .../hadoop-hdfs/src/site/markdown/ViewFs.md| 44 ++- .../fs/viewfs/TestViewFileSystemLinkFallback.java | 264 .../viewfs/TestViewFileSystemLinkMergeSlash.java | 234 ++ 9 files changed, 940 insertions(+), 68 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java index 8acd41f..5867f62 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ConfigUtil.java @@ -18,6 +18,7 @@ package org.apache.hadoop.fs.viewfs; import java.net.URI; +import java.util.Arrays; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.StringUtils; @@ -68,7 +69,72 @@ public class ConfigUtil { addLink( conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, src, target); } - + + /** + * Add a LinkMergeSlash to the config for the specified mount table. + * @param conf + * @param mountTableName + * @param target + */ + public static void addLinkMergeSlash(Configuration conf, + final String mountTableName, final URI target) { +conf.set(getConfigViewFsPrefix(mountTableName) + "." + +Constants.CONFIG_VIEWFS_LINK_MERGE_SLASH, target.toString()); + } + + /** + * Add a LinkMergeSlash to the config for the default mount table. + * @param conf + * @param target + */ + public static void addLinkMergeSlash(Configuration conf, final URI target) { +addLinkMergeSlash(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, +target); + } + + /** + * Add a LinkFallback to the config for the specified mount table. + * @param conf + * @param mountTableName + * @param target + */ + public static void addLinkFallback(Configuration conf, + final String mountTableName, final URI target) { +conf.set(getConfigViewFsPrefix(mountTableName) + "." + +Constants.CONFIG_VIEWFS_LINK_FALLBACK, target.toString()); + } + + /** + * Add a LinkFallback to the config for the default mount table. + * @param conf + * @param target + */ + public static void addLinkFallback(Configuration conf, final URI target) { +addLinkFallback(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, +target); + } + + /** + * Add a LinkMerge to the config for the specified mount table. + * @param conf + * @param mountTableName + * @param targets + */ + public static void addLinkMerge(Configuration conf, + final String mountTableName, final URI[] targets) { +conf.set(getConfigViewFsPrefix(mountTableName) + "." + +Constants.CONFIG_VIEWFS_LINK_MERGE, Arrays.toString(targets)); + } + + /** + * Add a LinkMerge to the config for the default mount table. + * @param conf + * @param targets + */ + public static void addLinkMerge(Configuration conf, final URI[] targets) { +addLinkMerge(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, targets); + } + /** * * @param conf diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java index 3f9aae2..7a0a6661 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/Constants.java @@ -51,12 +51,17 @@ public interface Constants { /** * Config variable for specifying a simple link */ - public static final String CONFIG_VIEWFS_LINK = "link"; - + String CONFIG_VIEWFS_LINK = "link"; + + /** + * Config variable for specifying a fallback for link mount points. + */ + String CONFIG_VIEWFS_LINK_FALLBACK = "linkFallback"; + /** * Config variable for specifying a merge link */ - public static final String CONFIG_VIEWFS_LINK_MERGE = "linkMerge"; + String CONFIG_VIEWFS_LINK_MERGE = "linkMerge"; /**