Bläddra i källkod

HDFS-12569. Unset EC policy logs empty payload in edit log. (Lei (Eddy) Xu)

(cherry picked from commit 0eab2fcac615228447e7f8bdf4b3ee742ea796ae)
Lei Xu 7 år sedan
förälder
incheckning
eb76d3dbec

+ 1 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirErasureCodingOp.java

@@ -298,8 +298,7 @@ final class FSDirErasureCodingOp {
 
     final List<XAttr> xattrs = Lists.newArrayListWithCapacity(1);
     xattrs.add(ecXAttr);
-    FSDirXAttrOp.unprotectedRemoveXAttrs(fsd, srcIIP, xattrs);
-    return xattrs;
+    return FSDirXAttrOp.unprotectedRemoveXAttrs(fsd, srcIIP, xattrs);
   }
 
   /**

+ 4 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java

@@ -184,6 +184,10 @@ class FSDirXAttrOp {
     return fsd.getAuditFileInfo(iip);
   }
 
+  /**
+   * Remove xattrs from the inode, and return the <em>removed</em> xattrs.
+   * @return the <em>removed</em> xattrs.
+   */
   static List<XAttr> unprotectedRemoveXAttrs(
       FSDirectory fsd, final INodesInPath iip, final List<XAttr> toRemove)
       throws IOException {

+ 13 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestUnsetAndChangeDirectoryEcPolicy.java

@@ -362,4 +362,17 @@ public class TestUnsetAndChangeDirectoryEcPolicy {
           + ecFilePath, e);
     }
   }
+
+  /**
+   * Test unsetEcPolicy is persisted correctly in edit log.
+   */
+  @Test
+  public void testUnsetEcPolicyInEditLog() throws IOException {
+    fs.getClient().setErasureCodingPolicy("/", ecPolicy.getName());
+    Assert.assertEquals(ecPolicy, fs.getErasureCodingPolicy(new Path("/")));
+    fs.getClient().unsetErasureCodingPolicy("/");
+
+    cluster.restartNameNode(true);
+    Assert.assertNull(fs.getErasureCodingPolicy(new Path("/")));
+  }
 }