HDFS-4801. lsSnapshottableDir throws IllegalArgumentException when root is snapshottable. Contributed by Jing Zhao
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2802@1479709 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0aab1ef996
commit
98b416f5ac
|
@ -341,3 +341,6 @@ Branch-2802 Snapshot (Unreleased)
|
|||
|
||||
HDFS-4800. Fix INodeDirectoryWithSnapshot#cleanDeletedINode. (Jing Zhao via
|
||||
szetszwo)
|
||||
|
||||
HDFS-4801. lsSnapshottableDir throws IllegalArgumentException when root is
|
||||
snapshottable. (Jing Zhao via szetszwo)
|
||||
|
|
|
@ -98,10 +98,17 @@ public class SnapshottableDirectoryStatus {
|
|||
* @return Full path of the file
|
||||
*/
|
||||
public Path getFullPath() {
|
||||
String parentFullPathStr = (parentFullPath == null || parentFullPath.length == 0) ? null
|
||||
: DFSUtil.bytes2String(parentFullPath);
|
||||
return parentFullPathStr == null ? new Path(dirStatus.getLocalName())
|
||||
: new Path(parentFullPathStr, dirStatus.getLocalName());
|
||||
String parentFullPathStr =
|
||||
(parentFullPath == null || parentFullPath.length == 0) ?
|
||||
null : DFSUtil.bytes2String(parentFullPath);
|
||||
if (parentFullPathStr == null
|
||||
&& dirStatus.getLocalNameInBytes().length == 0) {
|
||||
// root
|
||||
return new Path("/");
|
||||
} else {
|
||||
return parentFullPathStr == null ? new Path(dirStatus.getLocalName())
|
||||
: new Path(parentFullPathStr, dirStatus.getLocalName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -81,6 +81,19 @@ public class TestSnapshottableDirListing {
|
|||
SnapshottableDirectoryStatus[] dirs = hdfs.getSnapshottableDirListing();
|
||||
assertNull(dirs);
|
||||
|
||||
// Make root as snapshottable
|
||||
final Path root = new Path("/");
|
||||
hdfs.allowSnapshot(root);
|
||||
dirs = hdfs.getSnapshottableDirListing();
|
||||
assertEquals(1, dirs.length);
|
||||
assertEquals("", dirs[0].getDirStatus().getLocalName());
|
||||
assertEquals(root, dirs[0].getFullPath());
|
||||
|
||||
// Make root non-snaphsottable
|
||||
hdfs.disallowSnapshot(root);
|
||||
dirs = hdfs.getSnapshottableDirListing();
|
||||
assertNull(dirs);
|
||||
|
||||
// Make dir1 as snapshottable
|
||||
hdfs.allowSnapshot(dir1);
|
||||
dirs = hdfs.getSnapshottableDirListing();
|
||||
|
|
Loading…
Reference in New Issue