From ddf4e785475affead2f7c070b9f151de0fcb9024 Mon Sep 17 00:00:00 2001 From: Jing Zhao Date: Wed, 2 Sep 2015 11:45:45 -0700 Subject: [PATCH] HDFS-8937. Erasure coding: do not throw exception when setting replication factor on EC files. Contributed by Gao Rui. --- .../hadoop-hdfs/CHANGES-HDFS-EC-7285.txt | 3 +++ .../hadoop/hdfs/server/namenode/FSDirAttrOp.java | 9 +++------ .../org/apache/hadoop/hdfs/TestErasureCodingZones.java | 10 ++-------- 3 files changed, 8 insertions(+), 14 deletions(-) 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 28cc34aa922..fb464bf2af4 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) 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 4bed13ebc8a..46e172d3d69 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 @@ static BlockInfo[] unprotectedSetReplication( 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(); 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 a878501f5b0..b68aab99563 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 void testReplication() throws IOException { 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