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

Thomas Marquardt commented on HADOOP-15940:
-------------------------------------------

Thanks for putting this together.  Yes, for a Namespace enabled account, the 
Rename API has POSIX behavior and so the destination should not be adjusted as 
it currently is by the driver.

Note that when the source does not exist, the code in patch 001 on line 279 
AzureBlobFileSystem.java cannot return true.  It needs to throw 
FileNotFoundException.  Also, according to 
[https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/filesystem/filesystem.html#boolean_renamePath_src_Path_d],
 "Renaming a directory onto itself is a no-op; return value is not specified.  
In POSIX the result is False; in HDFS the result is True."  We should be able 
to return true for both renaming a directory onto itself and renaming a file 
onto itself.

Given the above, I think the fix is to skip the "adjust destination" code when 
namespace is enabled.
{noformat}
  public boolean rename(final Path src, final Path dst) throws IOException {
    LOG.debug(
        "AzureBlobFileSystem.rename src: {} dst: {}", src.toString(), 
dst.toString());

    Path parentFolder = src.getParent();
    if (parentFolder == null) {
      return false;
    }

    try {
      Path adjustedDst = dst;

      if (!getIsNamespaceEnabled()) {
        final FileStatus dstFileStatus = tryGetFileStatus(dst);
        String sourceFileName = src.getName();

        if (dstFileStatus != null) {
          if (!dstFileStatus.isDirectory()) {
            return src.equals(dst);
          }

          adjustedDst = new Path(dst, sourceFileName);
        }
      }

      Path qualifiedSrcPath = makeQualified(src);
      Path qualifiedDstPath = makeQualified(adjustedDst);
      performAbfsAuthCheck(FsAction.READ_WRITE, qualifiedSrcPath, 
qualifiedDstPath);

      abfsStore.rename(qualifiedSrcPath, qualifiedDstPath);
      return true;
    } catch(AzureBlobFileSystemException ex) {
      checkException(
              src,
              ex,
              AzureServiceErrorCode.PATH_ALREADY_EXISTS,
              AzureServiceErrorCode.INVALID_RENAME_SOURCE_PATH,
              AzureServiceErrorCode.SOURCE_PATH_NOT_FOUND,
              AzureServiceErrorCode.INVALID_SOURCE_OR_DESTINATION_RESOURCE_TYPE,
              AzureServiceErrorCode.RENAME_DESTINATION_PARENT_PATH_NOT_FOUND,
              AzureServiceErrorCode.INTERNAL_OPERATION_ABORT);
      return false;
    }

  }{noformat}

> ABFS: For HNS account, avoid unnecessary get call when doing Rename
> -------------------------------------------------------------------
>
>                 Key: HADOOP-15940
>                 URL: https://issues.apache.org/jira/browse/HADOOP-15940
>             Project: Hadoop Common
>          Issue Type: Sub-task
>          Components: fs/azure
>    Affects Versions: 3.2.0
>            Reporter: Da Zhou
>            Assignee: Da Zhou
>            Priority: Major
>         Attachments: HADOOP-15940-001.patch
>
>
> When rename, there is always a GET dst file status call, this is not 
> necessary.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to