Search in sources :

Example 1 with ECSchema

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);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ECSchema(org.apache.hadoop.io.erasurecode.ECSchema) ErasureCodingPolicy(org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) AccessControlException(org.apache.hadoop.security.AccessControlException) Test(org.junit.Test)

Example 2 with ECSchema

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());
    }
}
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

ErasureCodingPolicy (org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy)2 ECSchema (org.apache.hadoop.io.erasurecode.ECSchema)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Path (org.apache.hadoop.fs.Path)1 AddErasureCodingPolicyResponse (org.apache.hadoop.hdfs.protocol.AddErasureCodingPolicyResponse)1 AccessControlException (org.apache.hadoop.security.AccessControlException)1 Test (org.junit.Test)1 ActionException (org.smartdata.action.ActionException)1