HDFS-13838. WebHdfsFileSystem.getFileStatus() won't return correct "snapshot enabled" status. Contributed by Siyao Meng.
This commit is contained in:
parent
4441fe9201
commit
a1de8cbac5
|
@ -133,6 +133,7 @@ class JsonUtilClient {
|
||||||
Boolean aclBit = (Boolean) m.get("aclBit");
|
Boolean aclBit = (Boolean) m.get("aclBit");
|
||||||
Boolean encBit = (Boolean) m.get("encBit");
|
Boolean encBit = (Boolean) m.get("encBit");
|
||||||
Boolean erasureBit = (Boolean) m.get("ecBit");
|
Boolean erasureBit = (Boolean) m.get("ecBit");
|
||||||
|
Boolean snapshotEnabledBit = (Boolean) m.get("snapshotEnabled");
|
||||||
EnumSet<HdfsFileStatus.Flags> f =
|
EnumSet<HdfsFileStatus.Flags> f =
|
||||||
EnumSet.noneOf(HdfsFileStatus.Flags.class);
|
EnumSet.noneOf(HdfsFileStatus.Flags.class);
|
||||||
if (aclBit != null && aclBit) {
|
if (aclBit != null && aclBit) {
|
||||||
|
@ -144,6 +145,9 @@ class JsonUtilClient {
|
||||||
if (erasureBit != null && erasureBit) {
|
if (erasureBit != null && erasureBit) {
|
||||||
f.add(HdfsFileStatus.Flags.HAS_EC);
|
f.add(HdfsFileStatus.Flags.HAS_EC);
|
||||||
}
|
}
|
||||||
|
if (snapshotEnabledBit != null && snapshotEnabledBit) {
|
||||||
|
f.add(HdfsFileStatus.Flags.SNAPSHOT_ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Object> ecPolicyObj = (Map) m.get("ecPolicyObj");
|
Map<String, Object> ecPolicyObj = (Map) m.get("ecPolicyObj");
|
||||||
ErasureCodingPolicy ecPolicy = null;
|
ErasureCodingPolicy ecPolicy = null;
|
||||||
|
|
|
@ -482,6 +482,9 @@ public class TestWebHDFS {
|
||||||
|
|
||||||
// allow snapshots on /bar using webhdfs
|
// allow snapshots on /bar using webhdfs
|
||||||
webHdfs.allowSnapshot(bar);
|
webHdfs.allowSnapshot(bar);
|
||||||
|
// check if snapshot status is enabled
|
||||||
|
assertTrue(dfs.getFileStatus(bar).isSnapshotEnabled());
|
||||||
|
assertTrue(webHdfs.getFileStatus(bar).isSnapshotEnabled());
|
||||||
webHdfs.createSnapshot(bar, "s1");
|
webHdfs.createSnapshot(bar, "s1");
|
||||||
final Path s1path = SnapshotTestHelper.getSnapshotRoot(bar, "s1");
|
final Path s1path = SnapshotTestHelper.getSnapshotRoot(bar, "s1");
|
||||||
Assert.assertTrue(webHdfs.exists(s1path));
|
Assert.assertTrue(webHdfs.exists(s1path));
|
||||||
|
@ -491,15 +494,24 @@ public class TestWebHDFS {
|
||||||
assertEquals(bar, snapshottableDirs[0].getFullPath());
|
assertEquals(bar, snapshottableDirs[0].getFullPath());
|
||||||
dfs.deleteSnapshot(bar, "s1");
|
dfs.deleteSnapshot(bar, "s1");
|
||||||
dfs.disallowSnapshot(bar);
|
dfs.disallowSnapshot(bar);
|
||||||
|
// check if snapshot status is disabled
|
||||||
|
assertFalse(dfs.getFileStatus(bar).isSnapshotEnabled());
|
||||||
|
assertFalse(webHdfs.getFileStatus(bar).isSnapshotEnabled());
|
||||||
snapshottableDirs = dfs.getSnapshottableDirListing();
|
snapshottableDirs = dfs.getSnapshottableDirListing();
|
||||||
assertNull(snapshottableDirs);
|
assertNull(snapshottableDirs);
|
||||||
|
|
||||||
// disallow snapshots on /bar using webhdfs
|
// disallow snapshots on /bar using webhdfs
|
||||||
dfs.allowSnapshot(bar);
|
dfs.allowSnapshot(bar);
|
||||||
|
// check if snapshot status is enabled, again
|
||||||
|
assertTrue(dfs.getFileStatus(bar).isSnapshotEnabled());
|
||||||
|
assertTrue(webHdfs.getFileStatus(bar).isSnapshotEnabled());
|
||||||
snapshottableDirs = dfs.getSnapshottableDirListing();
|
snapshottableDirs = dfs.getSnapshottableDirListing();
|
||||||
assertEquals(1, snapshottableDirs.length);
|
assertEquals(1, snapshottableDirs.length);
|
||||||
assertEquals(bar, snapshottableDirs[0].getFullPath());
|
assertEquals(bar, snapshottableDirs[0].getFullPath());
|
||||||
webHdfs.disallowSnapshot(bar);
|
webHdfs.disallowSnapshot(bar);
|
||||||
|
// check if snapshot status is disabled, again
|
||||||
|
assertFalse(dfs.getFileStatus(bar).isSnapshotEnabled());
|
||||||
|
assertFalse(webHdfs.getFileStatus(bar).isSnapshotEnabled());
|
||||||
snapshottableDirs = dfs.getSnapshottableDirListing();
|
snapshottableDirs = dfs.getSnapshottableDirListing();
|
||||||
assertNull(snapshottableDirs);
|
assertNull(snapshottableDirs);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue