HDFS-12066. When Namenode is in safemode,may not allowed to remove an user's erasure coding policy. Contributed by lufei.

This commit is contained in:
Wei-Chiu Chuang 2017-08-15 07:41:10 -07:00
parent 1040bae6fc
commit e3ae3e2644
2 changed files with 12 additions and 0 deletions

View File

@ -7113,6 +7113,9 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
boolean success = false;
writeLock();
try {
checkOperation(OperationCategory.WRITE);
checkNameNodeSafeMode("Cannot remove erasure coding policy "
+ ecPolicyName);
FSDirErasureCodingOp.removeErasureCodePolicy(this, ecPolicyName);
success = true;
} finally {

View File

@ -482,6 +482,15 @@ public class TestSafeMode {
// expected
}
try {
dfs.removeErasureCodingPolicy("testECName");
fail("RemoveErasureCodingPolicy should have failed.");
} catch (IOException ioe) {
GenericTestUtils.assertExceptionContains(
"Cannot remove erasure coding policy", ioe);
// expected
}
assertFalse("Could not leave SM",
dfs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE));
}