From 25ebe6bfd7031f6d3550d964a5f4cf44f1286494 Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Sat, 9 Nov 2013 05:54:19 +0000 Subject: [PATCH] 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 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../org/apache/hadoop/hdfs/DistributedFileSystem.java | 10 ++++++---- .../src/test/resources/testCacheAdminConf.xml | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index de8f4525628..2d77109cdff 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -361,6 +361,9 @@ Trunk (Unreleased) 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 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index ed235aab664..c285dd574c1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -1637,9 +1637,8 @@ public RemoteIterator listPathBasedCacheDirectives( } if (filter.getPath() != null) { filter = new PathBasedCacheDirective.Builder(filter). - setPath(filter.getPath(). - makeQualified(getUri(), filter.getPath())). - build(); + setPath(new Path(getPathName(fixRelativePart(filter.getPath())))). + build(); } final RemoteIterator iter = dfs.listPathBasedCacheDirectives(filter); @@ -1651,8 +1650,11 @@ public boolean hasNext() throws IOException { @Override 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(); - Path p = desc.getPath().makeQualified(getUri(), desc.getPath()); + Path p = desc.getPath().makeQualified(getUri(), getWorkingDirectory()); return new PathBasedCacheDirective.Builder(desc).setPath(p).build(); } }; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCacheAdminConf.xml b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCacheAdminConf.xml index 8d389b4b749..54dd7a97b7d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCacheAdminConf.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/resources/testCacheAdminConf.xml @@ -335,7 +335,7 @@ -addDirective -path /bar -pool pool1 -addDirective -path /foo -pool pool2 -addDirective -path /bar -pool pool2 - -removeDirectives -path /foo + -removeDirectives -path ../../foo -listDirectives