Przeglądaj źródła

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 <umagangumalla@cloudera.com>
Uma Maheswara Rao G 4 lat temu
rodzic
commit
899dea2a21

+ 6 - 1
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.<mycluster>.linkFallBack)
+ * current uri as fallback( ex: fs.viewfs.mounttable.<mycluster>.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);
+  }
 }

+ 1 - 10
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<FileSystem> 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