|
@@ -23,6 +23,7 @@ import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.fs.Path;
|
|
|
import org.apache.hadoop.hdfs.protocol.SystemErasureCodingPolicies;
|
|
|
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
|
|
|
+import org.apache.hadoop.hdfs.protocol.NoECPolicySetException;
|
|
|
import org.apache.hadoop.io.erasurecode.CodecUtil;
|
|
|
import org.apache.hadoop.io.erasurecode.ErasureCodeNative;
|
|
|
import org.apache.hadoop.io.erasurecode.rawcoder.NativeRSRawErasureCoderFactory;
|
|
@@ -98,7 +99,11 @@ public class TestUnsetAndChangeDirectoryEcPolicy {
|
|
|
|
|
|
fs.mkdirs(dirPath);
|
|
|
// Test unset a directory which has no EC policy
|
|
|
- fs.unsetErasureCodingPolicy(dirPath);
|
|
|
+ try {
|
|
|
+ fs.unsetErasureCodingPolicy(dirPath);
|
|
|
+ fail();
|
|
|
+ } catch (NoECPolicySetException e) {
|
|
|
+ }
|
|
|
// Set EC policy on directory
|
|
|
fs.setErasureCodingPolicy(dirPath, ecPolicy.getName());
|
|
|
|
|
@@ -126,8 +131,8 @@ public class TestUnsetAndChangeDirectoryEcPolicy {
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * Test nested directory with different EC policy.
|
|
|
- */
|
|
|
+ * Test nested directory with different EC policy.
|
|
|
+ */
|
|
|
@Test
|
|
|
public void testNestedEcPolicy() throws Exception {
|
|
|
final int numBlocks = 1;
|
|
@@ -199,7 +204,11 @@ public class TestUnsetAndChangeDirectoryEcPolicy {
|
|
|
final Path replicateFilePath = new Path(rootPath, "rep_file");
|
|
|
|
|
|
// Test unset root path which has no EC policy
|
|
|
- fs.unsetErasureCodingPolicy(rootPath);
|
|
|
+ try {
|
|
|
+ fs.unsetErasureCodingPolicy(rootPath);
|
|
|
+ fail();
|
|
|
+ } catch (NoECPolicySetException e) {
|
|
|
+ }
|
|
|
// Set EC policy on root path
|
|
|
fs.setErasureCodingPolicy(rootPath, ecPolicy.getName());
|
|
|
DFSTestUtil.createFile(fs, ecFilePath, fileLen, (short) 1, 0L);
|
|
@@ -238,7 +247,11 @@ public class TestUnsetAndChangeDirectoryEcPolicy {
|
|
|
final ErasureCodingPolicy ec32Policy = SystemErasureCodingPolicies
|
|
|
.getByID(SystemErasureCodingPolicies.RS_3_2_POLICY_ID);
|
|
|
|
|
|
- fs.unsetErasureCodingPolicy(rootPath);
|
|
|
+ try {
|
|
|
+ fs.unsetErasureCodingPolicy(rootPath);
|
|
|
+ fail();
|
|
|
+ } catch (NoECPolicySetException e) {
|
|
|
+ }
|
|
|
fs.setErasureCodingPolicy(rootPath, ecPolicy.getName());
|
|
|
// Create RS(6,3) EC policy file
|
|
|
DFSTestUtil.createFile(fs, ec63FilePath, fileLen, (short) 1, 0L);
|