use of org.apache.hadoop.io.erasurecode.ECSchema in project hadoop by apache.
the class TestErasureCodingPolicies method testSetInvalidPolicy.
@Test
public void testSetInvalidPolicy() throws IOException {
ECSchema rsSchema = new ECSchema("rs", 4, 2);
String policyName = "RS-4-2-128k";
int cellSize = 128 * 1024;
ErasureCodingPolicy ecPolicy = new ErasureCodingPolicy(policyName, rsSchema, cellSize, (byte) -1);
String src = "/ecDir4-2";
final Path ecDir = new Path(src);
try {
fs.mkdir(ecDir, FsPermission.getDirDefault());
fs.getClient().setErasureCodingPolicy(src, ecPolicy.getName());
fail("HadoopIllegalArgumentException should be thrown for" + "setting an invalid erasure coding policy");
} catch (Exception e) {
assertExceptionContains("Policy 'RS-4-2-128k' does not match " + "any enabled erasure coding policies", e);
}
}
use of org.apache.hadoop.io.erasurecode.ECSchema in project SSM by Intel-bigdata.
the class AddErasureCodingPolicy method execute.
@Override
public void execute() throws Exception {
this.setDfsClient(HadoopUtil.getDFSClient(HadoopUtil.getNameNodeUri(conf), conf));
if (codecName == null || numDataUnits <= 0 || numParityUnits <= 0 || cellSize <= 0 || cellSize % 1024 != 0) {
throw new ActionException("Illegal EC policy Schema! " + "A valid codec name should be given, " + "the dataNum, parityNum and cellSize should be positive and " + "the cellSize should be divisible by 1024.");
}
ECSchema ecSchema = new ECSchema(codecName, numDataUnits, numParityUnits);
ErasureCodingPolicy ecPolicy = new ErasureCodingPolicy(ecSchema, cellSize);
AddErasureCodingPolicyResponse addEcResponse = dfsClient.addErasureCodingPolicies(new ErasureCodingPolicy[] { ecPolicy })[0];
if (addEcResponse.isSucceed()) {
appendLog(String.format("EC policy named %s is added successfully!", addEcResponse.getPolicy().getName()));
} else {
appendLog(String.format("Failed to add the given EC policy!"));
throw new ActionException(addEcResponse.getErrorMsg());
}
}
Aggregations