HDFS-11933. Arguments check for ErasureCodingPolicy->composePolicyName. Contributed by Lu Fei
This commit is contained in:
parent
1a598479a9
commit
a010b330e7
|
@ -58,6 +58,8 @@ public final class ErasureCodingPolicy {
|
|||
}
|
||||
|
||||
public static String composePolicyName(ECSchema schema, int cellSize) {
|
||||
Preconditions.checkNotNull(schema);
|
||||
Preconditions.checkArgument(cellSize > 0, "cellSize must be positive");
|
||||
Preconditions.checkArgument(cellSize % 1024 == 0,
|
||||
"cellSize must be 1024 aligned");
|
||||
return schema.getCodecName().toUpperCase() + "-" +
|
||||
|
|
|
@ -51,6 +51,28 @@ public class TestErasureCodingPolicy {
|
|||
} catch (IllegalArgumentException e) {
|
||||
GenericTestUtils.assertExceptionContains("cellSize", e);
|
||||
}
|
||||
try {
|
||||
new ErasureCodingPolicy(null, 1024, (byte) -1);
|
||||
fail("Instantiated invalid ErasureCodingPolicy");
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
try {
|
||||
new ErasureCodingPolicy(SCHEMA_1, -1, (byte) -1);
|
||||
fail("Instantiated invalid ErasureCodingPolicy");
|
||||
} catch (IllegalArgumentException e) {
|
||||
GenericTestUtils.assertExceptionContains("cellSize", e);
|
||||
}
|
||||
try {
|
||||
new ErasureCodingPolicy(null, 1024);
|
||||
fail("Instantiated invalid ErasureCodingPolicy");
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
try {
|
||||
new ErasureCodingPolicy(SCHEMA_1, -1);
|
||||
fail("Instantiated invalid ErasureCodingPolicy");
|
||||
} catch (IllegalArgumentException e) {
|
||||
GenericTestUtils.assertExceptionContains("cellSize", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue