Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-19130

FTPFileSystem rename with full qualified path broken

VotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.20.2, 3.3.3, 3.3.4, 3.3.6
    • 3.5.0
    • fs
    • Reviewed

    Description

         When use fs shell to put/rename file in ftp server with full qualified path , it always get "Input/output error"(eg. ftp://user:password@localhost/pathxxx), the reason is that changeWorkingDirectory command underneath is being passed a string with file:// uri prefix which will not be understand by ftp server

       

      in our case, after client.changeWorkingDirectory("ftp://mytest:mytest@10.5.xx.xx/files")

      executed, the workingDirectory of ftp server is still "/", which is incorrect(not understand by ftp server)

      the solution should be pass absoluteSrc.getParent().toUri().getPath().toString to avoid
      file:// uri prefix, like this: 

      --- a/FTPFileSystem.java
      +++ b/FTPFileSystem.java
      @@ -549,15 +549,15 @@ public class FTPFileSystem extends FileSystem {
             throw new IOException("Destination path " + dst
                 + " already exist, cannot rename!");
           }
      -    String parentSrc = absoluteSrc.getParent().toUri().toString();
      -    String parentDst = absoluteDst.getParent().toUri().toString();
      +    URI parentSrc = absoluteSrc.getParent().toUri();
      +    URI parentDst = absoluteDst.getParent().toUri();
           String from = src.getName();
           String to = dst.getName();
      -    if (!parentSrc.equals(parentDst)) {
      +    if (!parentSrc.toString().equals(parentDst.toString())) {
             throw new IOException("Cannot rename parent(source): " + parentSrc
                 + ", parent(destination):  " + parentDst);
           }
      -    client.changeWorkingDirectory(parentSrc);
      +    client.changeWorkingDirectory(parentSrc.getPath().toString());
           boolean renamed = client.rename(from, to);
           return renamed;
         }

      already related issue  as follows 
      https://issues.apache.org/jira/browse/HADOOP-8653

      I create this issue and add related unit test.

       

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            zhangjian16 shawn
            zhangjian16 shawn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified

                Slack

                  Issue deployment