Skip to content

Commit 7fc6ba0

Browse files
cndaiminarp7
authored andcommitted
CDPD-40022. HDFS-16430. Add validation to maximum blocks in EC group when adding an EC policy (apache#3899). Contributed by daimin.
Reviewed-by: tomscut <[email protected]> Signed-off-by: Ayush Saxena <[email protected]> (cherry picked from commit 5ef335d) Conflicts: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java (cherry picked from commit 728ed10) Conflicts: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java Change-Id: Id779f8e3a16350d9793f079087ae30278b13483a
1 parent c403b26 commit 7fc6ba0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ErasureCodingPolicyManager.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.google.common.annotations.VisibleForTesting;
2121
import com.google.common.base.Preconditions;
22+
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
2223
import org.apache.hadoop.HadoopIllegalArgumentException;
2324
import org.apache.hadoop.classification.InterfaceAudience;
2425
import org.apache.hadoop.conf.Configuration;
@@ -304,6 +305,12 @@ public synchronized ErasureCodingPolicy addPolicy(
304305
+ policy.getCodecName() + " is not supported");
305306
}
306307

308+
int blocksInGroup = policy.getNumDataUnits() + policy.getNumParityUnits();
309+
if (blocksInGroup > HdfsServerConstants.MAX_BLOCKS_IN_GROUP) {
310+
throw new HadoopIllegalArgumentException("Number of data and parity blocks in an EC group " +
311+
blocksInGroup + " should not exceed maximum " + HdfsServerConstants.MAX_BLOCKS_IN_GROUP);
312+
}
313+
307314
if (policy.getCellSize() > maxCellSize) {
308315
throw new HadoopIllegalArgumentException("Cell size " +
309316
policy.getCellSize() + " should not exceed maximum " +

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestErasureCodingPolicies.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,15 @@ public void testAddErasureCodingPolicies() throws Exception {
749749
assertEquals(1, responses.length);
750750
assertFalse(responses[0].isSucceed());
751751

752+
// Test numDataUnits + numParityUnits > 16
753+
toAddSchema = new ECSchema("rs", 14, 4);
754+
newPolicy =
755+
new ErasureCodingPolicy(toAddSchema, 128 * 1024 * 1024);
756+
policyArray = new ErasureCodingPolicy[]{newPolicy};
757+
responses = fs.addErasureCodingPolicies(policyArray);
758+
assertEquals(1, responses.length);
759+
assertFalse(responses[0].isSucceed());
760+
752761
// Test too big cell size
753762
toAddSchema = new ECSchema("rs", 3, 2);
754763
newPolicy =

0 commit comments

Comments
 (0)