Repository: hadoop Updated Branches: refs/heads/branch-3.1 3a13fa1b7 -> 595ce9457
HDFS-13886. HttpFSFileSystem.getFileStatus() doesn't return "snapshot enabled" bit. Contributed by Siyao Meng. (cherry picked from commit 44857476fa993fbf9c97f979b91e19d27632c10a) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/595ce945 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/595ce945 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/595ce945 Branch: refs/heads/branch-3.1 Commit: 595ce945704f37a4df5cb8c9b2c509b8d6a14ec4 Parents: 3a13fa1 Author: Wei-Chiu Chuang <[email protected]> Authored: Tue Sep 18 15:33:02 2018 -0700 Committer: Wei-Chiu Chuang <[email protected]> Committed: Tue Sep 18 15:40:10 2018 -0700 ---------------------------------------------------------------------- .../hadoop/fs/http/client/HttpFSFileSystem.java | 2 +- .../hadoop/fs/http/server/FSOperations.java | 3 ++ .../fs/http/client/BaseTestHttpFSWith.java | 35 +++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/595ce945/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSFileSystem.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSFileSystem.java index ce76f05..dd285d4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSFileSystem.java @@ -199,7 +199,7 @@ public class HttpFSFileSystem extends FileSystem public static final String ENC_BIT_JSON = "encBit"; public static final String EC_BIT_JSON = "ecBit"; - public static final String SNAPSHOT_BIT_JSON = "seBit"; + public static final String SNAPSHOT_BIT_JSON = "snapshotEnabled"; public static final String DIRECTORY_LISTING_JSON = "DirectoryListing"; public static final String PARTIAL_LISTING_JSON = "partialListing"; http://git-wip-us.apache.org/repos/asf/hadoop/blob/595ce945/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java index 1d47a61..a3c45c79 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/server/FSOperations.java @@ -120,6 +120,9 @@ public class FSOperations { if (fileStatus.getPermission().getErasureCodedBit()) { json.put(HttpFSFileSystem.EC_BIT_JSON, true); } + if (fileStatus.isSnapshotEnabled()) { + json.put(HttpFSFileSystem.SNAPSHOT_BIT_JSON, true); + } return json; } http://git-wip-us.apache.org/repos/asf/hadoop/blob/595ce945/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java index a6dce4d..8dabdea 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java +++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java @@ -376,6 +376,35 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase { Assert.assertEquals(stati[0].getPath(), statl[0].getPath()); } + private void testFileStatusAttr() throws Exception { + if (!this.isLocalFS()) { + // Create a directory + Path path = new Path("/tmp/tmp-snap-test"); + DistributedFileSystem distributedFs = (DistributedFileSystem) FileSystem + .get(path.toUri(), this.getProxiedFSConf()); + distributedFs.mkdirs(path); + // Get the FileSystem instance that's being tested + FileSystem fs = this.getHttpFSFileSystem(); + // Check FileStatus + assertFalse("Snapshot should be disallowed by default", + fs.getFileStatus(path).isSnapshotEnabled()); + // Allow snapshot + distributedFs.allowSnapshot(path); + // Check FileStatus + assertTrue("Snapshot enabled bit is not set in FileStatus", + fs.getFileStatus(path).isSnapshotEnabled()); + // Disallow snapshot + distributedFs.disallowSnapshot(path); + // Check FileStatus + assertFalse("Snapshot enabled bit is not cleared in FileStatus", + fs.getFileStatus(path).isSnapshotEnabled()); + // Cleanup + fs.delete(path, true); + fs.close(); + distributedFs.close(); + } + } + private static void assertSameListing(FileSystem expected, FileSystem actual, Path p) throws IOException { // Consume all the entries from both iterators @@ -1041,7 +1070,8 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase { SET_REPLICATION, CHECKSUM, CONTENT_SUMMARY, FILEACLS, DIRACLS, SET_XATTR, GET_XATTRS, REMOVE_XATTR, LIST_XATTRS, ENCRYPTION, LIST_STATUS_BATCH, GETTRASHROOT, STORAGEPOLICY, ERASURE_CODING, - CREATE_SNAPSHOT, RENAME_SNAPSHOT, DELETE_SNAPSHOT + CREATE_SNAPSHOT, RENAME_SNAPSHOT, DELETE_SNAPSHOT, + FILE_STATUS_ATTR } private void operation(Operation op) throws Exception { @@ -1139,6 +1169,9 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase { case DELETE_SNAPSHOT: testDeleteSnapshot(); break; + case FILE_STATUS_ATTR: + testFileStatusAttr(); + break; } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
