From 899dea2a21d1016dff2bef9e22b9f9c7b908067f Mon Sep 17 00:00:00 2001 From: Uma Maheswara Rao G Date: Fri, 25 Sep 2020 21:21:01 -0700 Subject: [PATCH] HDFS-15598: ViewHDFS#canonicalizeUri should not be restricted to DFS only API. (#2339). Contributed by Uma Maheswara Rao G. Co-authored-by: Uma Maheswara Rao G --- .../fs/viewfs/ViewFileSystemOverloadScheme.java | 7 ++++++- .../apache/hadoop/hdfs/ViewDistributedFileSystem.java | 11 +---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystemOverloadScheme.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystemOverloadScheme.java index 5353e93b6f1..60d14d38516 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystemOverloadScheme.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystemOverloadScheme.java @@ -97,7 +97,7 @@ import static org.apache.hadoop.fs.viewfs.Constants.CONFIG_VIEWFS_IGNORE_PORT_IN * the mount table name. * (3) If there are no mount links configured with the initializing uri's * hostname as the mount table name, then it will automatically consider the - * current uri as fallback( ex: fs.viewfs.mounttable..linkFallBack) + * current uri as fallback( ex: fs.viewfs.mounttable..linkFallback) * target fs uri. *****************************************************************************/ @InterfaceAudience.LimitedPrivate({ "MapReduce", "HBase", "Hive" }) @@ -354,4 +354,9 @@ public class ViewFileSystemOverloadScheme extends ViewFileSystem { .getMyFs(); } + @Override + @InterfaceAudience.LimitedPrivate("HDFS") + public URI canonicalizeUri(URI uri) { + return super.canonicalizeUri(uri); + } } \ No newline at end of file diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ViewDistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ViewDistributedFileSystem.java index 2894a244a47..70ba886b978 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ViewDistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ViewDistributedFileSystem.java @@ -1072,16 +1072,7 @@ public class ViewDistributedFileSystem extends DistributedFileSystem { return super.canonicalizeUri(uri); } - ViewFileSystemOverloadScheme.MountPathInfo mountPathInfo = null; - try { - mountPathInfo = this.vfs.getMountPathInfo(new Path(uri), getConf()); - } catch (IOException e) { - LOGGER.warn("Failed to resolve the uri as mount path", e); - return null; - } - checkDFS(mountPathInfo.getTargetFs(), "canonicalizeUri"); - return ((DistributedFileSystem) mountPathInfo.getTargetFs()) - .canonicalizeUri(uri); + return vfs.canonicalizeUri(uri); } @Override