From f4a9faaa7e03bb795f06983a0f79d1d5926d1882 Mon Sep 17 00:00:00 2001 From: zhangbutao Date: Sat, 12 Oct 2024 01:37:49 -0400 Subject: [PATCH] [Test]: Reduce hdfs filesystem rpc call --- .../hadoop/hive/metastore/Warehouse.java | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java index 2952276020c7..5bf0da8652e4 100755 --- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java +++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java @@ -151,33 +151,24 @@ public FileSystem getFs(Path f) throws MetaException { * @return Path with canonical scheme and authority */ public static Path getDnsPath(Path path, Configuration conf) throws MetaException { - if (isBlobStorageScheme(conf, path.toUri().getScheme())) { - String scheme = path.toUri().getScheme(); - String authority = path.toUri().getAuthority(); - URI defaultUri = FileSystem.getDefaultUri(conf); - if ((authority == null && scheme == null) - || StringUtils.equalsIgnoreCase(scheme, defaultUri.getScheme())) { - if (authority == null) { - authority = defaultUri.getAuthority(); - } - if (scheme == null) { - scheme = defaultUri.getScheme(); - } - String uriPath = path.toUri().getPath(); - if (StringUtils.isEmpty(uriPath)) { - uriPath = "/"; - } - return new Path(scheme, authority, uriPath); + String scheme = path.toUri().getScheme(); + String authority = path.toUri().getAuthority(); + URI defaultUri = FileSystem.getDefaultUri(conf); + if ((authority == null && scheme == null) + || StringUtils.equalsIgnoreCase(scheme, defaultUri.getScheme())) { + if (authority == null) { + authority = defaultUri.getAuthority(); + } + if (scheme == null) { + scheme = defaultUri.getScheme(); } - return path; - } else { // fallback: for other FS type make the FS instance - FileSystem fs = getFs(path, conf); String uriPath = path.toUri().getPath(); if (StringUtils.isEmpty(uriPath)) { uriPath = "/"; } - return (new Path(fs.getUri().getScheme(), fs.getUri().getAuthority(), uriPath)); + return new Path(scheme, authority, uriPath); } + return path; } private static boolean isBlobStorageScheme(Configuration conf, String scheme) {