HDFS-5482. DistributedFileSystem#listPathBasedCacheDirectives must support relative paths. Contributed by Colin Patrick McCabe.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1540257 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2013-11-09 05:54:19 +00:00
parent 37bc8e0c14
commit 25ebe6bfd7
3 changed files with 10 additions and 5 deletions

View File

@ -361,6 +361,9 @@ Trunk (Unreleased)
HDFS-5394. Fix race conditions in DN caching and uncaching (cmccabe) HDFS-5394. Fix race conditions in DN caching and uncaching (cmccabe)
HDFS-5482. DistributedFileSystem#listPathBasedCacheDirectives must support
relative paths. (Colin Patrick McCabe via cnauroth)
Release 2.3.0 - UNRELEASED Release 2.3.0 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -1637,9 +1637,8 @@ public class DistributedFileSystem extends FileSystem {
} }
if (filter.getPath() != null) { if (filter.getPath() != null) {
filter = new PathBasedCacheDirective.Builder(filter). filter = new PathBasedCacheDirective.Builder(filter).
setPath(filter.getPath(). setPath(new Path(getPathName(fixRelativePart(filter.getPath())))).
makeQualified(getUri(), filter.getPath())). build();
build();
} }
final RemoteIterator<PathBasedCacheDirective> iter = final RemoteIterator<PathBasedCacheDirective> iter =
dfs.listPathBasedCacheDirectives(filter); dfs.listPathBasedCacheDirectives(filter);
@ -1651,8 +1650,11 @@ public class DistributedFileSystem extends FileSystem {
@Override @Override
public PathBasedCacheDirective next() throws IOException { public PathBasedCacheDirective next() throws IOException {
// Although the paths we get back from the NameNode should always be
// absolute, we call makeQualified to add the scheme and authority of
// this DistributedFilesystem.
PathBasedCacheDirective desc = iter.next(); PathBasedCacheDirective desc = iter.next();
Path p = desc.getPath().makeQualified(getUri(), desc.getPath()); Path p = desc.getPath().makeQualified(getUri(), getWorkingDirectory());
return new PathBasedCacheDirective.Builder(desc).setPath(p).build(); return new PathBasedCacheDirective.Builder(desc).setPath(p).build();
} }
}; };

View File

@ -335,7 +335,7 @@
<cache-admin-command>-addDirective -path /bar -pool pool1</cache-admin-command> <cache-admin-command>-addDirective -path /bar -pool pool1</cache-admin-command>
<cache-admin-command>-addDirective -path /foo -pool pool2</cache-admin-command> <cache-admin-command>-addDirective -path /foo -pool pool2</cache-admin-command>
<cache-admin-command>-addDirective -path /bar -pool pool2</cache-admin-command> <cache-admin-command>-addDirective -path /bar -pool pool2</cache-admin-command>
<cache-admin-command>-removeDirectives -path /foo</cache-admin-command> <cache-admin-command>-removeDirectives -path ../../foo</cache-admin-command>
<cache-admin-command>-listDirectives</cache-admin-command> <cache-admin-command>-listDirectives</cache-admin-command>
</test-commands> </test-commands>
<cleanup-commands> <cleanup-commands>