Author: wang Date: Wed Nov 20 00:29:59 2013 New Revision: 1543670 URL: http://svn.apache.org/r1543670 Log: HDFS-5513. CacheAdmin commands fail when using . as the path. Contributed by Andrew Wang.
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/PathBasedCacheDirective.java hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestPathBasedCacheRequests.java Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1543670&r1=1543669&r2=1543670&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Wed Nov 20 00:29:59 2013 @@ -379,7 +379,9 @@ Trunk (Unreleased) nextEntryId (cmccabe) HDFS-5512. CacheAdmin -listPools fails with NPE when user lacks permissions - to view all pools (awang via cmccabe) + to view all pools (wang via cmccabe) + + HDFS-5513. CacheAdmin commands fail when using . as the path. (wang) Release 2.3.0 - UNRELEASED Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/PathBasedCacheDirective.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/PathBasedCacheDirective.java?rev=1543670&r1=1543669&r2=1543670&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/PathBasedCacheDirective.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/PathBasedCacheDirective.java Wed Nov 20 00:29:59 2013 @@ -17,8 +17,6 @@ */ package org.apache.hadoop.hdfs.protocol; -import java.net.URI; - import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.hadoop.classification.InterfaceAudience; @@ -61,9 +59,7 @@ public class PathBasedCacheDirective { */ public Builder(PathBasedCacheDirective directive) { this.id = directive.getId(); - // deep-copy URI - URI uri = directive.getPath().toUri(); - this.path = new Path(uri.getScheme(), uri.getAuthority(), uri.getPath()); + this.path = directive.getPath(); this.replication = directive.getReplication(); this.pool = directive.getPool(); } Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestPathBasedCacheRequests.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestPathBasedCacheRequests.java?rev=1543670&r1=1543669&r2=1543670&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestPathBasedCacheRequests.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestPathBasedCacheRequests.java Wed Nov 20 00:29:59 2013 @@ -31,9 +31,8 @@ import static org.junit.Assert.assertTru import static org.junit.Assert.fail; import java.io.IOException; -import java.nio.MappedByteBuffer; -import java.security.PrivilegedExceptionAction; import java.nio.ByteBuffer; +import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; @@ -59,7 +58,6 @@ import org.apache.hadoop.hdfs.protocol.C import org.apache.hadoop.hdfs.protocol.PathBasedCacheDirective; import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor.CachedBlocksList.Type; import org.apache.hadoop.hdfs.server.namenode.EditLogFileOutputStream; -import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.MappableBlock; import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols; import org.apache.hadoop.io.nativeio.NativeIO; import org.apache.hadoop.io.nativeio.NativeIO.POSIX.CacheManipulator; @@ -482,6 +480,15 @@ public class TestPathBasedCacheRequests dfs.removePathBasedCacheDirective(relativeId); iter = dfs.listPathBasedCacheDirectives(null); assertFalse(iter.hasNext()); + + // Verify that PBCDs with path "." work correctly + PathBasedCacheDirective directive = + new PathBasedCacheDirective.Builder().setPath(new Path(".")) + .setPool("pool1").build(); + long id = dfs.addPathBasedCacheDirective(directive); + dfs.modifyPathBasedCacheDirective(new PathBasedCacheDirective.Builder( + directive).setId(id).setReplication((short)2).build()); + dfs.removePathBasedCacheDirective(id); } @Test(timeout=60000)