Search in sources :

Example 1 with AddErasureCodingPolicyResponse

use of org.apache.hadoop.hdfs.protocol.AddErasureCodingPolicyResponse 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());
    }
}
Also used : ECSchema(org.apache.hadoop.io.erasurecode.ECSchema) ErasureCodingPolicy(org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy) AddErasureCodingPolicyResponse(org.apache.hadoop.hdfs.protocol.AddErasureCodingPolicyResponse) ActionException(org.smartdata.action.ActionException)

Aggregations

AddErasureCodingPolicyResponse (org.apache.hadoop.hdfs.protocol.AddErasureCodingPolicyResponse)1 ErasureCodingPolicy (org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy)1 ECSchema (org.apache.hadoop.io.erasurecode.ECSchema)1 ActionException (org.smartdata.action.ActionException)1