|
@@ -993,10 +993,10 @@ public class RouterClientProtocol implements ClientProtocol {
|
|
|
if (dates != null && dates.containsKey(src)) {
|
|
|
date = dates.get(src);
|
|
|
}
|
|
|
- ret = getMountPointStatus(src, children.size(), date);
|
|
|
+ ret = getMountPointStatus(src, children.size(), date, false);
|
|
|
} else if (children != null) {
|
|
|
// The src is a mount point, but there are no files or directories
|
|
|
- ret = getMountPointStatus(src, 0, 0);
|
|
|
+ ret = getMountPointStatus(src, 0, 0, false);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2193,6 +2193,21 @@ public class RouterClientProtocol implements ClientProtocol {
|
|
|
@VisibleForTesting
|
|
|
HdfsFileStatus getMountPointStatus(
|
|
|
String name, int childrenNum, long date) {
|
|
|
+ return getMountPointStatus(name, childrenNum, date, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Create a new file status for a mount point.
|
|
|
+ *
|
|
|
+ * @param name Name of the mount point.
|
|
|
+ * @param childrenNum Number of children.
|
|
|
+ * @param date Map with the dates.
|
|
|
+ * @param setPath if true should set path in HdfsFileStatus
|
|
|
+ * @return New HDFS file status representing a mount point.
|
|
|
+ */
|
|
|
+ @VisibleForTesting
|
|
|
+ HdfsFileStatus getMountPointStatus(
|
|
|
+ String name, int childrenNum, long date, boolean setPath) {
|
|
|
long modTime = date;
|
|
|
long accessTime = date;
|
|
|
FsPermission permission = FsPermission.getDirDefault();
|
|
@@ -2242,17 +2257,20 @@ public class RouterClientProtocol implements ClientProtocol {
|
|
|
}
|
|
|
}
|
|
|
long inodeId = 0;
|
|
|
- Path path = new Path(name);
|
|
|
- String nameStr = path.getName();
|
|
|
- return new HdfsFileStatus.Builder()
|
|
|
- .isdir(true)
|
|
|
+ HdfsFileStatus.Builder builder = new HdfsFileStatus.Builder();
|
|
|
+ if (setPath) {
|
|
|
+ Path path = new Path(name);
|
|
|
+ String nameStr = path.getName();
|
|
|
+ builder.path(DFSUtil.string2Bytes(nameStr));
|
|
|
+ }
|
|
|
+
|
|
|
+ return builder.isdir(true)
|
|
|
.mtime(modTime)
|
|
|
.atime(accessTime)
|
|
|
.perm(permission)
|
|
|
.owner(owner)
|
|
|
.group(group)
|
|
|
.symlink(new byte[0])
|
|
|
- .path(DFSUtil.string2Bytes(nameStr))
|
|
|
.fileId(inodeId)
|
|
|
.children(childrenNum)
|
|
|
.flags(flags)
|