[ 
https://issues.apache.org/jira/browse/HADOOP-2567?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Chris Douglas updated HADOOP-2567:
----------------------------------

    Attachment: 2567-3.patch

Would it be make sense to use UserGroupInformation to determine the home dir? 
Something like:

{{code:java}}
(DistributedFileSystem)
public void initialize(URI uri, Configuration conf) throws IOException {
  ...
  try {
    this.workingDir = getHomeDirectory(UserGroupInformation.login(conf));
  } catch (LoginException e) {
    throw (IOException)new IOException("Could not set working 
dir").initCause(e);
    // this.workingDir = getHomeDirectory(); // ?
  }
}

(FileSystem)
Path getHomeDirectory(UserGroupInformation ugi) {
  return new Path("/user/" + ugi.getUserName()).makeQualified(this);
}
{{code}}

A failed login could also set the default as it is now, i.e. using 
System.getProperty. I'm not sure of the best option in that case.

The best reason for this: agents can just use the credentials/conf from the 
user to resolve relative paths as in: 
setWorkingDirectory(getHomeDirectory(ticket)).

This would probably only apply to DistributedFileSystem. The attached patch 
retains FileSystem::getHomeDirectory(), but a null ugi and/or overrides that 
ignore it would probably be at least as clean.

> add FileSystem#getHomeDirectory() method
> ----------------------------------------
>
>                 Key: HADOOP-2567
>                 URL: https://issues.apache.org/jira/browse/HADOOP-2567
>             Project: Hadoop
>          Issue Type: New Feature
>          Components: fs
>            Reporter: Doug Cutting
>            Assignee: Doug Cutting
>             Fix For: 0.16.0
>
>         Attachments: 2567-3.patch, HADOOP-2567-1.patch, HADOOP-2567-2.patch, 
> HADOOP-2567.patch
>
>
> The FileSystem API would benefit from a getHomeDirectory() method.
> The default implementation would return "/user/$USER/".
> RawLocalFileSystem would return System.getProperty("user.home").
> HADOOP-2514 can use this to implement per-user trash.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to