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 GitBox <gi...@apache.org> on 2020/01/09 05:00:52 UTC

[GitHub] [hadoop] jojochuang commented on a change in pull request #1758: HDFS-15052. WebHDFS getTrashRoot leads to OOM due to FileSystem objec…

jojochuang commented on a change in pull request #1758: HDFS-15052. WebHDFS getTrashRoot leads to OOM due to FileSystem objec…
URL: https://github.com/apache/hadoop/pull/1758#discussion_r364554258
 
 

 ##########
 File path: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/web/resources/NamenodeWebHdfsMethods.java
 ##########
 @@ -1345,11 +1348,21 @@ protected Response get(
     }
   }
 
-  private static String getTrashRoot(String fullPath,
-      Configuration conf) throws IOException {
-    FileSystem fs = FileSystem.get(conf != null ? conf : new Configuration());
-    return fs.getTrashRoot(
-        new org.apache.hadoop.fs.Path(fullPath)).toUri().getPath();
+  private String getTrashRoot(String fullPath) throws IOException {
+    String user = UserGroupInformation.getCurrentUser().getShortUserName();
+    org.apache.hadoop.fs.Path path = new org.apache.hadoop.fs.Path(fullPath);
+    String parentSrc = path.isRoot() ?
+        path.toUri().getPath() : path.getParent().toUri().getPath();
+    EncryptionZone ez = getRpcClientProtocol().getEZForPath(parentSrc);
+    org.apache.hadoop.fs.Path trashRoot;
+    if (ez != null) {
+      trashRoot = new org.apache.hadoop.fs.Path(
+          new org.apache.hadoop.fs.Path(ez.getPath(), TRASH_PREFIX), user);
+    } else {
+      trashRoot = new org.apache.hadoop.fs.Path(
+          new org.apache.hadoop.fs.Path(USER_HOME_PREFIX, user), TRASH_PREFIX);
+    }
+    return trashRoot.toUri().getPath();
 
 Review comment:
   This change assumes namenode's default fs is a DistributedFileSystem, which makes sense.
   The change basically copies the implementation inside DistributedFileSystem#getTrashRoot(). If that method evolves in the future, the same changes should be applied in here too. 
   
   Can we add a comment inside DistributedFileSystem#getTrashRoot(), that any change should be added in NamenodeWebHdfsMethods#getTrashRoot() too?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org