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 6dd1f658947..7d29b8f44ca 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
@@ -66,8 +66,7 @@ public class ConfigUtil {
*/
public static void addLink(final Configuration conf, final String src,
final URI target) {
- addLink( conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE,
- src, target);
+ addLink(conf, getDefaultMountTableName(conf), src, target);
}
/**
@@ -88,8 +87,7 @@ public class ConfigUtil {
* @param target
*/
public static void addLinkMergeSlash(Configuration conf, final URI target) {
- addLinkMergeSlash(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE,
- target);
+ addLinkMergeSlash(conf, getDefaultMountTableName(conf), target);
}
/**
@@ -110,8 +108,7 @@ public class ConfigUtil {
* @param target
*/
public static void addLinkFallback(Configuration conf, final URI target) {
- addLinkFallback(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE,
- target);
+ addLinkFallback(conf, getDefaultMountTableName(conf), target);
}
/**
@@ -132,7 +129,7 @@ public class ConfigUtil {
* @param targets
*/
public static void addLinkMerge(Configuration conf, final URI[] targets) {
- addLinkMerge(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, targets);
+ addLinkMerge(conf, getDefaultMountTableName(conf), targets);
}
/**
@@ -166,8 +163,7 @@ public class ConfigUtil {
public static void addLinkNfly(final Configuration conf, final String src,
final URI ... targets) {
- addLinkNfly(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, src, null,
- targets);
+ addLinkNfly(conf, getDefaultMountTableName(conf), src, null, targets);
}
/**
@@ -177,8 +173,7 @@ public class ConfigUtil {
*/
public static void setHomeDirConf(final Configuration conf,
final String homedir) {
- setHomeDirConf( conf,
- Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE, homedir);
+ setHomeDirConf(conf, getDefaultMountTableName(conf), homedir);
}
/**
@@ -202,7 +197,7 @@ public class ConfigUtil {
* @return home dir value, null if variable is not in conf
*/
public static String getHomeDirValue(final Configuration conf) {
- return getHomeDirValue(conf, Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE);
+ return getHomeDirValue(conf, getDefaultMountTableName(conf));
}
/**
@@ -216,4 +211,18 @@ public class ConfigUtil {
return conf.get(getConfigViewFsPrefix(mountTableName) + "." +
Constants.CONFIG_VIEWFS_HOMEDIR);
}
+
+ /**
+ * Get the name of the default mount table to use. If
+ * {@link Constants#CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE_NAME_KEY} is specified,
+ * it's value is returned. Otherwise,
+ * {@link Constants#CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE} is returned.
+ *
+ * @param conf Configuration to use.
+ * @return the name of the default mount table to use.
+ */
+ public static String getDefaultMountTableName(final Configuration conf) {
+ return conf.get(Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE_NAME_KEY,
+ Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE);
+ }
}
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 f454f63084c..28ebf73cf55 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
@@ -41,12 +41,18 @@ public interface Constants {
* then the hadoop default value (/user) is used.
*/
public static final String CONFIG_VIEWFS_HOMEDIR = "homedir";
-
+
+ /**
+ * Config key to specify the name of the default mount table.
+ */
+ String CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE_NAME_KEY =
+ "fs.viewfs.mounttable.default.name.key";
+
/**
* Config variable name for the default mount table.
*/
public static final String CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE = "default";
-
+
/**
* Config variable full prefix for the default mount table.
*/
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java
index d1e5d3a4e5f..3d709b13bfc 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java
@@ -465,7 +465,7 @@ abstract class InodeTree {
FileAlreadyExistsException, IOException {
String mountTableName = viewName;
if (mountTableName == null) {
- mountTableName = Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE;
+ mountTableName = ConfigUtil.getDefaultMountTableName(config);
}
homedirPrefix = ConfigUtil.getHomeDirValue(config, mountTableName);
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAuthorityLocalFs.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAuthorityLocalFs.java
index 2e498f2c0a0..fd5de72ed71 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAuthorityLocalFs.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAuthorityLocalFs.java
@@ -48,10 +48,9 @@ public class TestViewFsWithAuthorityLocalFs extends ViewFsBaseTest {
fcTarget = FileContext.getLocalFSFileContext();
super.setUp(); // this sets up conf (and fcView which we replace)
- // Now create a viewfs using a mount table called "default"
- // hence viewfs://default/
+ // Now create a viewfs using a mount table using the {MOUNT_TABLE_NAME}
schemeWithAuthority =
- new URI(FsConstants.VIEWFS_SCHEME, "default", "/", null, null);
+ new URI(FsConstants.VIEWFS_SCHEME, MOUNT_TABLE_NAME, "/", null, null);
fcView = FileContext.getFileContext(schemeWithAuthority, conf);
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
index 90722aab2f8..21b0c159e2a 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
@@ -97,6 +97,8 @@ import org.junit.Test;
*
*/
abstract public class ViewFsBaseTest {
+ protected static final String MOUNT_TABLE_NAME = "mycluster";
+
FileContext fcView; // the view file system - the mounts are here
FileContext fcTarget; // the target file system - the mount will point here
Path targetTestRoot;
@@ -130,6 +132,9 @@ abstract public class ViewFsBaseTest {
// Set up the defaultMT in the config with our mount point links
conf = new Configuration();
+ conf.set(
+ Constants.CONFIG_VIEWFS_DEFAULT_MOUNT_TABLE_NAME_KEY,
+ MOUNT_TABLE_NAME);
ConfigUtil.addLink(conf, "/targetRoot", targetTestRoot.toUri());
ConfigUtil.addLink(conf, "/user",
new Path(targetTestRoot,"user").toUri());
@@ -1011,9 +1016,8 @@ abstract public class ViewFsBaseTest {
userUgi.doAs(new PrivilegedExceptionAction