[ 
https://issues.apache.org/jira/browse/HDFS-4019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13721211#comment-13721211
 ] 

Andrew Wang commented on HDFS-4019:
-----------------------------------

Hey Colin, nice patch. Some comments:

- New FileContext#getFileLinkStatus(Path[]) method is almost the same as the 
getFileStatus(Path[]). Can we break it out into an internal method with a 
resolveLink flag?
- Unrelated to this patch, but I noticed that globStatusInternal's {{boolean[] 
hasGlob}} never uses anything except {{hasGlob[0]}}. Can we make it just a 
plain boolean?

In FileSystem#globStatusInternal:
{code}
    // remove anything that didn't match the filter
    if (!matches.isEmpty()) {
      Iterator<FileStatus> iter = matches.iterator();
      while (iter.hasNext()) {
        if (!filter.accept(iter.next().getPath())) {
          iter.remove();
        }
      }
    }
{code}

This code has me worried because of the resolution in HDFS-5026. 
{{FileStatus#getPath}} returns a path with intermediate symlinks resolved. This 
would be okay if PathFilters only matched against the last path component, but 
they don't.

FileContext does this right since it carefully constructs parent paths first 
via {{FileContext#globPathsLevel}}, and also pushes filtering responsibilities 
into {{listStatus}}. Maybe we can just call/borrow FC's impl, because I could 
see this being annoying to fix in FileSystem.

- I see the new {{Ln}} command creates symlinks without the {{-s}} flag. I know 
we don't have hardlinks, but I'd like to see the {{-s}} flag to match GNU ln.
- Ln's description could also be beefed up. Maybe something like:

{noformat}
Creates a link from the <link_path> to <target path>.
For symbolic links, the target does not need to exist.
Symbolic link targets are stored as-is and can be
relative, absolute, or fully-qualified Paths.

Currently, this command only supports creation of
symbolic links.

  -s Creates a symbolic link.
{noformat}
                
> FSShell should support creating symlinks
> ----------------------------------------
>
>                 Key: HDFS-4019
>                 URL: https://issues.apache.org/jira/browse/HDFS-4019
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: tools
>    Affects Versions: 2.0.3-alpha
>            Reporter: Colin Patrick McCabe
>            Assignee: Colin Patrick McCabe
>            Priority: Minor
>         Attachments: HDFS-4019.001.patch
>
>
> FSShell should support creating symlinks.  This would allow users to create 
> symlinks from the shell without having to write a Java program.
> One thing that makes this complicated is that FSShell currently uses 
> FileSystem internally, and symlinks are currently only supported by the 
> FileContext API.  So either FSShell would have to be ported to FileContext, 
> or symlinks would have to be added to FileSystem.  Or perhaps we could open a 
> FileContext only when symlinks were necessary, but that seems messy.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to