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

This commit is contained in:
Jing Zhao 2015-09-02 11:45:45 -07:00
parent 53358fe680
commit ddf4e78547
3 changed files with 8 additions and 14 deletions

View File

@ -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)

View File

@ -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();

View File

@ -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