HDFS-8937. Erasure coding: do not throw exception when setting replication factor on EC files. Contributed by Gao Rui.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ddf4e785 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ddf4e785 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ddf4e785 Branch: refs/heads/HDFS-7240 Commit: ddf4e785475affead2f7c070b9f151de0fcb9024 Parents: 53358fe Author: Jing Zhao <ji...@apache.org> Authored: Wed Sep 2 11:45:45 2015 -0700 Committer: Jing Zhao <ji...@apache.org> Committed: Wed Sep 2 11:45:45 2015 -0700 ---------------------------------------------------------------------- hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt | 3 +++ .../apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java | 9 +++------ .../org/apache/hadoop/hdfs/TestErasureCodingZones.java | 10 ++-------- 3 files changed, 8 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/ddf4e785/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt index 28cc34a..fb464bf 100755 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt +++ b/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) http://git-wip-us.apache.org/repos/asf/hadoop/blob/ddf4e785/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java index 4bed13e..46e172d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java +++ b/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(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/ddf4e785/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestErasureCodingZones.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestErasureCodingZones.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestErasureCodingZones.java index a878501..b68aab9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestErasureCodingZones.java +++ b/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