use of org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy 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