You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "slfan1989 (via GitHub)" <gi...@apache.org> on 2023/08/30 01:49:11 UTC
[GitHub] [hadoop] slfan1989 commented on a diff in pull request #5992: HDFS-17168. Support getTrashRoots API in WebHDFS
slfan1989 commented on code in PR #5992:
URL: https://github.com/apache/hadoop/pull/5992#discussion_r1309521869
##########
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java:
##########
@@ -877,6 +878,40 @@ public static Map<String, String> getErasureCodeCodecs(Map<?, ?> json) {
return map;
}
+ public static Collection<FileStatus> getTrashRoots(Map<?, ?> json) {
+ List<?> objs = (List<?>) json.get("Paths");
+ if (objs != null) {
+ FileStatus[] trashRoots = new FileStatus[objs.size()];
+ for (int i = 0; i < objs.size(); i++) {
+ Map<?, ?> m = (Map<?, ?>) objs.get(i);
+ trashRoots[i] = toFileStatus(m);
+ }
+ return Arrays.asList(trashRoots);
+ }
+ return new ArrayList<FileStatus>(0);
+ }
+
+ public static FileStatus toFileStatus(Map<?, ?> json) {
+ Path path = new Path(getString(json, "path", ""));
+ long length = getLong(json, "length", 0);
+ boolean isdir = getBoolean(json, "isdir", false);
Review Comment:
Can "isdir" be a constant?
##########
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java:
##########
@@ -877,6 +878,40 @@ public static Map<String, String> getErasureCodeCodecs(Map<?, ?> json) {
return map;
}
+ public static Collection<FileStatus> getTrashRoots(Map<?, ?> json) {
+ List<?> objs = (List<?>) json.get("Paths");
+ if (objs != null) {
+ FileStatus[] trashRoots = new FileStatus[objs.size()];
+ for (int i = 0; i < objs.size(); i++) {
+ Map<?, ?> m = (Map<?, ?>) objs.get(i);
+ trashRoots[i] = toFileStatus(m);
+ }
+ return Arrays.asList(trashRoots);
+ }
+ return new ArrayList<FileStatus>(0);
+ }
+
+ public static FileStatus toFileStatus(Map<?, ?> json) {
+ Path path = new Path(getString(json, "path", ""));
+ long length = getLong(json, "length", 0);
+ boolean isdir = getBoolean(json, "isdir", false);
Review Comment:
Can "isdir" be a constant?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org