瀏覽代碼

HDFS-8937. Erasure coding: do not throw exception when setting replication factor on EC files. Contributed by Gao Rui.

Jing Zhao 9 年之前
父節點
當前提交
ddf4e78547

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt

@@ -406,3 +406,6 @@
 
     HDFS-8909. Erasure coding: update BlockInfoContiguousUC and BlockInfoStripedUC
     to use BlockUnderConstructionFeature. (Jing Zhao via waltersu4549)
+
+    HDFS-8937. Erasure coding: do not throw exception when setting replication on
+    EC file. (Gao Rui via jing9)

+ 3 - 6
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java

@@ -405,15 +405,12 @@ public class FSDirAttrOp {
     final BlockManager bm = fsd.getBlockManager();
     final INodesInPath iip = fsd.getINodesInPath4Write(src, true);
     final INode inode = iip.getLastINode();
-    if (inode == null || !inode.isFile()) {
+    if (inode == null || !inode.isFile() || inode.asFile().isStriped()) {
+      // TODO we do not support replication on stripe layout files yet
       return null;
     }
-    INodeFile file = inode.asFile();
-    if (file.isStriped()) {
-      throw new UnsupportedActionException(
-          "Cannot set replication to a file with striped blocks");
-    }
 
+    INodeFile file = inode.asFile();
     // Make sure the directory has sufficient quotas
     short oldBR = file.getPreferredBlockReplication();
 

+ 2 - 8
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestErasureCodingZones.java

@@ -166,14 +166,8 @@ public class TestErasureCodingZones {
     fs.create(fooFile, FsPermission.getFileDefault(), true,
         conf.getInt(CommonConfigurationKeys.IO_FILE_BUFFER_SIZE_KEY, 4096),
         (short)0, fs.getDefaultBlockSize(fooFile), null);
-
-    try {
-      fs.setReplication(fooFile, (short) 3);
-      fail("Shouldn't allow to set replication to a file with striped blocks");
-    } catch (IOException e) {
-      assertExceptionContains(
-          "Cannot set replication to a file with striped blocks", e);
-    }
+    // set replication should be a no-op
+    fs.setReplication(fooFile, (short) 3);
   }
 
   @Test