xinglin commented on code in PR #5071:
URL: https://github.com/apache/hadoop/pull/5071#discussion_r1006029768
##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java:
##########
@@ -723,6 +723,78 @@ public boolean delete(String src, boolean recursive)
throws IOException {
}
}
+ /**
+ * Create missing user home dirs for trash paths.
+ *
+ * When there are multiple possible destination locations for a trash path,
+ * we create user home dirs at all destination locations.
+ *
+ * We assume the router is running with super-user privilege (can create
+ * user home dir in /user dir).
+ *
+ * @param src source location
+ * @param locations destination locations
+ */
+ private void createUserHomeForTrashPath(String src,
+ List<RemoteLocation> locations)
+ throws IOException {
+ List<RemoteLocation> userHomes = new ArrayList<>();
+ List<RemoteLocation> missingUserHomes = new ArrayList<>();
+
+ // Get home dirs for trash paths
+ for (RemoteLocation loc : locations) {
+
+ String path = loc.getDest();
+ // Continue if not a trash path
+ if (!MountTableResolver.isTrashPath(path)) {
+ continue;
+ }
+
+ String trashRoot = MountTableResolver.getTrashRoot();
+ String userHome = new Path(trashRoot).getParent().toUri().getPath();
+ RemoteLocation userHomeLoc = new RemoteLocation(loc, userHome);
+ userHomes.add(userHomeLoc);
+ }
+
+ // Use getFileInfo to identify missing user homes
+ for (RemoteLocation userHomeLoc : userHomes) {
+ RemoteMethod method =
+ new RemoteMethod("getFileInfo", new Class<?>[]{String.class},
+ new RemoteParam());
+ HdfsFileStatus ret =
+ rpcClient.invokeSingle(userHomeLoc, method, HdfsFileStatus.class);
+ if (ret == null) {
+ missingUserHomes.add(userHomeLoc);
+ }
+ }
+
+ // Create missing user home dirs and set owner
+ for(RemoteLocation loc: missingUserHomes) {
Review Comment:
I don't think this function is too complicated. It just does two things:
first check whether a home dir exists and then create these home dirs which
don't exist yet.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]