|
@@ -105,6 +105,7 @@ import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.regex.Pattern;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
import static org.junit.Assert.assertArrayEquals;
|
|
|
import static org.junit.Assert.assertEquals;
|
|
@@ -1218,9 +1219,9 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
|
|
|
FILE_STATUS_ATTR, GET_SNAPSHOT_DIFF, GET_SNAPSHOTTABLE_DIRECTORY_LIST,
|
|
|
GET_SNAPSHOT_LIST, GET_SERVERDEFAULTS, CHECKACCESS, SETECPOLICY,
|
|
|
SATISFYSTORAGEPOLICY, GET_SNAPSHOT_DIFF_LISTING, GETFILEBLOCKLOCATIONS,
|
|
|
- GETFILELINKSTATUS, GETSTATUS, GETECPOLICIES
|
|
|
+ GETFILELINKSTATUS, GETSTATUS, GETECPOLICIES, GETECCODECS
|
|
|
}
|
|
|
-
|
|
|
+ @SuppressWarnings("methodlength")
|
|
|
private void operation(Operation op) throws Exception {
|
|
|
switch (op) {
|
|
|
case GET:
|
|
@@ -1370,6 +1371,9 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
|
|
|
case GETECPOLICIES:
|
|
|
testGetAllEEPolicies();
|
|
|
break;
|
|
|
+ case GETECCODECS:
|
|
|
+ testGetECCodecs();
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2149,6 +2153,54 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void testGetECCodecs() throws Exception {
|
|
|
+ if (isLocalFS()) {
|
|
|
+ // do not test the testGetECCodecs for local FS.
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ final Path path = new Path("/foo");
|
|
|
+
|
|
|
+ FileSystem fs = FileSystem.get(path.toUri(), this.getProxiedFSConf());
|
|
|
+ LambdaTestUtils.intercept(AssertionError.class, () -> {
|
|
|
+ if (!(fs instanceof DistributedFileSystem)) {
|
|
|
+ throw new AssertionError(fs.getClass().getSimpleName() +
|
|
|
+ " is not of type DistributedFileSystem.");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ DistributedFileSystem dfs =
|
|
|
+ (DistributedFileSystem) FileSystem.get(path.toUri(), this.getProxiedFSConf());
|
|
|
+ FileSystem httpFs = this.getHttpFSFileSystem();
|
|
|
+
|
|
|
+ Map<String, String> dfsErasureCodingCodecs = dfs.getAllErasureCodingCodecs();
|
|
|
+
|
|
|
+ final AtomicReference<Map<String, String>> diffErasureCodingCodecsRef =
|
|
|
+ new AtomicReference<>();
|
|
|
+ LambdaTestUtils.intercept(AssertionError.class, () -> {
|
|
|
+ if (httpFs instanceof HttpFSFileSystem) {
|
|
|
+ HttpFSFileSystem httpFSFileSystem = (HttpFSFileSystem) httpFs;
|
|
|
+ diffErasureCodingCodecsRef.set(httpFSFileSystem.getAllErasureCodingCodecs());
|
|
|
+ } else if (httpFs instanceof WebHdfsFileSystem) {
|
|
|
+ WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) httpFs;
|
|
|
+ diffErasureCodingCodecsRef.set(webHdfsFileSystem.getAllErasureCodingCodecs());
|
|
|
+ } else {
|
|
|
+ throw new AssertionError(httpFs.getClass().getSimpleName() +
|
|
|
+ " is not of type HttpFSFileSystem or WebHdfsFileSystem");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Map<String, String> diffErasureCodingCodecs = diffErasureCodingCodecsRef.get();
|
|
|
+
|
|
|
+ //Validate testGetECCodecs are the same as DistributedFileSystem
|
|
|
+ Assert.assertEquals(dfsErasureCodingCodecs.size(), diffErasureCodingCodecs.size());
|
|
|
+
|
|
|
+ for (Map.Entry<String, String> entry : dfsErasureCodingCodecs.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ Assert.assertTrue(diffErasureCodingCodecs.containsKey(key));
|
|
|
+ Assert.assertEquals(value, diffErasureCodingCodecs.get(key));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void assertHttpFsReportListingWithDfsClient(SnapshotDiffReportListing diffReportListing,
|
|
|
SnapshotDiffReportListing dfsDiffReportListing) {
|
|
|
Assert.assertEquals(diffReportListing.getCreateList().size(),
|