Skip to content

Commit

Permalink
[Test]: Reduce hdfs filesystem rpc call
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbutao committed Oct 12, 2024
1 parent e8923aa commit f4a9faa
Showing 1 changed file with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f4a9faa

Please sign in to comment.