瀏覽代碼

HADOOP-3995. In case of quota failure on HDFS, rename does not restore
source filename. (rangadi)


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.18@689328 13f79535-47bb-0310-9956-ffa450edef68

Raghu Angadi 17 年之前
父節點
當前提交
0f0239b1fb
共有 3 個文件被更改,包括 20 次插入1 次删除
  1. 3 0
      CHANGES.txt
  2. 3 0
      src/hdfs/org/apache/hadoop/dfs/FSDirectory.java
  3. 14 1
      src/test/org/apache/hadoop/dfs/TestQuota.java

+ 3 - 0
CHANGES.txt

@@ -4,6 +4,9 @@ Release 0.18.1 - Unreleased
 
   BUG FIXES
 
+    HADOOP-3995. In case of quota failure on HDFS, rename does not restore
+    source filename. (rangadi)
+
     HADOOP-3821. Prevent SequenceFile and IFile from duplicating codecs in
     CodecPool when closed more than once. (Arun Murthy via cdouglas)
 

+ 3 - 0
src/hdfs/org/apache/hadoop/dfs/FSDirectory.java

@@ -371,6 +371,8 @@ class FSDirectory implements FSConstants, Closeable {
         return false;
       }
 
+      String srcChildName = srcChild.getLocalName();
+      
       // check the validity of the destination
       INode dstChild = null;
       QuotaExceededException failureByQuota = null;
@@ -412,6 +414,7 @@ class FSDirectory implements FSConstants, Closeable {
             +"failed to rename "+src+" to "+dst);
         try {
           // put it back
+          srcChild.setLocalName(srcChildName);
           addChild(srcInodes, srcInodes.length-1, srcChild, false);
         } catch (IOException ignored) {}
         if (failureByQuota != null) {

+ 14 - 1
src/test/org/apache/hadoop/dfs/TestQuota.java

@@ -266,7 +266,7 @@ public class TestQuota extends TestCase {
       assertEquals(c.getDirectoryCount(), 6);
       assertEquals(c.getQuota(), 6);
 
-      // 10: Move /nqdir0/qdir1/qdir21/nqdir30 to /nqdir0/qdir1/qdir21
+      // 10: Move /nqdir0/qdir1/qdir20/nqdir30 to /nqdir0/qdir1/qdir21
       hasException = false;
       try {
         assertFalse(dfs.rename(tempPath, quotaDir3));
@@ -274,6 +274,19 @@ public class TestQuota extends TestCase {
         hasException = true;
       }
       assertTrue(hasException);
+      assertTrue(dfs.exists(tempPath));
+      assertFalse(dfs.exists(new Path(quotaDir3, "nqdir30")));
+      
+      // 10.a: Rename /nqdir0/qdir1/qdir20/nqdir30 to /nqdir0/qdir1/qdir21/nqdir32
+      hasException = false;
+      try {
+        assertFalse(dfs.rename(tempPath, new Path(quotaDir3, "nqdir32")));
+      } catch (QuotaExceededException e) {
+        hasException = true;
+      }
+      assertTrue(hasException);
+      assertTrue(dfs.exists(tempPath));
+      assertFalse(dfs.exists(new Path(quotaDir3, "nqdir32")));
 
       // 11: Move /nqdir0/qdir1/qdir20/nqdir30 to /nqdir0
       assertTrue(dfs.rename(tempPath, new Path("/nqdir0")));