diff --git shims/src/common/java/org/apache/hadoop/fs/ProxyFileSystem.java shims/src/common/java/org/apache/hadoop/fs/ProxyFileSystem.java index 212091a..f364fc9 100644 --- shims/src/common/java/org/apache/hadoop/fs/ProxyFileSystem.java +++ shims/src/common/java/org/apache/hadoop/fs/ProxyFileSystem.java @@ -77,6 +77,19 @@ public class ProxyFileSystem extends FilterFileSystem { } /** + * + * @param p + * @return + * @throws IOException + */ + public Path resolvePath(final Path p) throws IOException { + // Return the fully-qualified path of path f resolving the path + // through any symlinks or mount point + checkPath(p); + return getFileStatus(p).getPath(); + } + + /** * Create a proxy file system for fs. * * @param fs FileSystem to create proxy for @@ -124,8 +137,34 @@ public class ProxyFileSystem extends FilterFileSystem { @Override - protected void checkPath(Path path) { - super.checkPath(swizzleParamPath(path)); + protected void checkPath(final Path path) { + URI thatUri = path.toUri(); + String thatScheme = thatUri.getScheme(); + if (thatScheme == null) // fs is relative + return; + if (myScheme.equalsIgnoreCase(thatScheme)) { + String thatAuthority = thatUri.getAuthority(); + if (thatAuthority == null && // path's authority is null, use the default + myAuthority != null) { // fs has an authority + URI defaultUri = getDefaultUri(getConf()); + if (myScheme.equalsIgnoreCase(defaultUri.getScheme())) { + thatUri = defaultUri; // schemes match, so use this uri instead + } else { + thatUri = null; // can't determine auth of the path + } + } + if (thatUri != null) { + thatAuthority = thatUri.getAuthority(); + if (myAuthority == thatAuthority || // authorities match + (myAuthority != null && + myAuthority.equalsIgnoreCase(thatAuthority))) + super.checkPath(swizzleParamPath(path)); + return; + } + + } + throw new IllegalArgumentException("Wrong FS: " + path + + ", expected: " + this.getUri()); } @Override