File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
hadoop-hdfs-project/hadoop-hdfs/src
main/java/org/apache/hadoop/hdfs/server/namenode
test/java/org/apache/hadoop/hdfs Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 1919
2020import com .google .common .annotations .VisibleForTesting ;
2121import com .google .common .base .Preconditions ;
22+ import org .apache .hadoop .hdfs .server .common .HdfsServerConstants ;
2223import org .apache .hadoop .HadoopIllegalArgumentException ;
2324import org .apache .hadoop .classification .InterfaceAudience ;
2425import 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 " +
Original file line number Diff line number Diff line change @@ -747,6 +747,15 @@ public void testAddErasureCodingPolicies() throws Exception {
747747 assertEquals (1 , responses .length );
748748 assertFalse (responses [0 ].isSucceed ());
749749
750+ // Test numDataUnits + numParityUnits > 16
751+ toAddSchema = new ECSchema ("rs" , 14 , 4 );
752+ newPolicy =
753+ new ErasureCodingPolicy (toAddSchema , 128 * 1024 * 1024 );
754+ policyArray = new ErasureCodingPolicy []{newPolicy };
755+ responses = fs .addErasureCodingPolicies (policyArray );
756+ assertEquals (1 , responses .length );
757+ assertFalse (responses [0 ].isSucceed ());
758+
750759 // Test too big cell size
751760 toAddSchema = new ECSchema ("rs" , 3 , 2 );
752761 newPolicy =
You can’t perform that action at this time.
0 commit comments