hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sur...@apache.org
Subject svn commit: r825689 - in /hadoop/hdfs/trunk: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java src/test/hdfs/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java src/test/hdfs/org/apache/hadoop/hdfs/TestDFSRename.java
Date Thu, 15 Oct 2009 22:43:45 GMT
Author: suresh
Date: Thu Oct 15 22:43:44 2009
New Revision: 825689

URL: http://svn.apache.org/viewvc?rev=825689&view=rev
Log:
HDFS-709. Fix TestDFSShell failure due to rename bug introduced by HDFS-677. Contributed by
Suresh Srinivas.

Modified:
    hadoop/hdfs/trunk/CHANGES.txt
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSRename.java

Modified: hadoop/hdfs/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/CHANGES.txt?rev=825689&r1=825688&r2=825689&view=diff
==============================================================================
--- hadoop/hdfs/trunk/CHANGES.txt (original)
+++ hadoop/hdfs/trunk/CHANGES.txt Thu Oct 15 22:43:44 2009
@@ -435,3 +435,6 @@
 
     HDFS-677. Rename failure when both source and destination quota exceeds
     results in deletion of source. (suresh)
+
+    HDFS-709. Fix TestDFSShell failure due to rename bug introduced by 
+    HDFS-677. (suresh)

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java?rev=825689&r1=825688&r2=825689&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java (original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java Thu
Oct 15 22:43:44 2009
@@ -413,7 +413,9 @@
       if (dst.equals(src)) {
         return true;
       }
-      if (dst.startsWith(src)) {
+      // dst cannot be directory or a file under src
+      if (dst.startsWith(src) && 
+          dst.charAt(src.length()) == Path.SEPARATOR_CHAR) {
         NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedRenameTo: "
             + "failed to rename " + src + " to " + dst
             + " because destination starts with src");

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java?rev=825689&r1=825688&r2=825689&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java
(original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java
Thu Oct 15 22:43:44 2009
@@ -92,15 +92,20 @@
     fs.setQuota(dst1.getParent(), FSConstants.QUOTA_DONT_SET,
         FSConstants.QUOTA_DONT_SET);
 
-    // Test1: src does not exceed quota and dst has quota to accommodate rename
+    // Test1: src does not exceed quota and dst has no quota check and hence 
+    // accommodates rename
     rename(src1, dst1, true, false);
 
     // Test2: src does not exceed quota and dst has *no* quota to accommodate
-    // rename
+    // rename. 
+
+    // testRenameWithQuota/dstDir now has quota = 1 and dst1 already uses it
     fs.setQuota(dst1.getParent(), 1, FSConstants.QUOTA_DONT_SET);
     rename(src2, dst2, false, true);
 
     // Test3: src exceeds quota and dst has *no* quota to accommodate rename
+    
+    // src1 has no quota to accommodate new rename node
     fs.setQuota(src1.getParent(), 1, FSConstants.QUOTA_DONT_SET);
     rename(dst1, src1, false, true);
   }

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSRename.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSRename.java?rev=825689&r1=825688&r2=825689&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSRename.java (original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/TestDFSRename.java Thu Oct 15 22:43:44
2009
@@ -38,6 +38,12 @@
     }
   }
 
+  static void createFile(FileSystem fs, Path f) throws IOException {
+    DataOutputStream a_out = fs.create(f);
+    a_out.writeBytes("something");
+    a_out.close();
+  }
+  
   public void testRename() throws Exception {
     Configuration conf = new HdfsConfiguration();
     MiniDFSCluster cluster = new MiniDFSCluster(conf, 2, true, null);
@@ -50,9 +56,7 @@
         Path aa = new Path(dir, "aa");
         Path b = new Path(dir, "b");
   
-        DataOutputStream a_out = fs.create(a);
-        a_out.writeBytes("something");
-        a_out.close();
+        createFile(fs, a);
         
         //should not have any lease
         assertEquals(0, countLease(cluster)); 
@@ -78,26 +82,37 @@
         assertFalse(fs.exists(dstPath));
         assertFalse(fs.rename(dir, dstPath));
       }
-
-      { // test rename /a/b to /a/b/c
+      
+      { // dst cannot be a file or directory under src
+        // test rename /a/b/foo to /a/b/c
         Path src = new Path("/a/b");
         Path dst = new Path("/a/b/c");
 
-        DataOutputStream a_out = fs.create(new Path(src, "foo"));
-        a_out.writeBytes("something");
-        a_out.close();
+        createFile(fs, new Path(src, "foo"));
+        
+        // dst cannot be a file under src
+        assertFalse(fs.rename(src, dst)); 
         
-        assertFalse(fs.rename(src, dst));
+        // dst cannot be a directory under src
+        assertFalse(fs.rename(src.getParent(), dst.getParent())); 
       }
       
-      { // test rename /a/b/c to /a/b/c
+      { // dst can start with src, if it is not a directory or file under src
+        // test rename /test /testfile
+        Path src = new Path("/testPrefix");
+        Path dst = new Path("/testPrefixfile");
+
+        createFile(fs, src);
+        assertTrue(fs.rename(src, dst));
+      }
+      
+      { // dst should not be same as src test rename /a/b/c to /a/b/c
         Path src = new Path("/a/b/c");
-        DataOutputStream a_out = fs.create(src);
-        a_out.writeBytes("something");
-        a_out.close();
+        createFile(fs, src);
         assertTrue(fs.rename(src, src));
+        assertFalse(fs.rename(new Path("/a/b"), new Path("/a/b/")));
+        assertTrue(fs.rename(src, new Path("/a/b/c/")));
       }
-      
       fs.delete(dir, true);
     } finally {
       if (cluster != null) {cluster.shutdown();}



Mime
View raw message