hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [2/2] hadoop git commit: HADOOP-15940. ABFS: For HNS account, avoid unnecessary get call when doing Rename.
Date Tue, 27 Nov 2018 18:13:23 GMT
HADOOP-15940. ABFS: For HNS account, avoid unnecessary get call when doing Rename.

Contributed by Da Zhou <da.zhou@microsoft.com>

(cherry picked from commit 1a3a4960d91aa594283e447963fb2e407d4c6af5)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/300f772c
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/300f772c
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/300f772c

Branch: refs/heads/trunk
Commit: 300f772c36da7e616afbf94df19238d6ac70e69d
Parents: 96c104d
Author: Da Zhou <da.zhou@microsoft.com>
Authored: Tue Nov 27 18:13:07 2018 +0000
Committer: Steve Loughran <stevel@apache.org>
Committed: Tue Nov 27 18:13:07 2018 +0000

----------------------------------------------------------------------
 .../hadoop/fs/azurebfs/AzureBlobFileSystem.java | 32 +++++++++++++++++---
 1 file changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/300f772c/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java
b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java
index 7d80542..38b0c77 100644
--- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java
+++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java
@@ -271,22 +271,44 @@ public class AzureBlobFileSystem extends FileSystem {
     if (parentFolder == null) {
       return false;
     }
+    Path qualifiedSrcPath = makeQualified(src);
+    Path qualifiedDstPath = makeQualified(dst);
+
+    // rename under same folder;
+    if(makeQualified(parentFolder).equals(qualifiedDstPath)) {
+      return tryGetFileStatus(qualifiedSrcPath) != null;
+    }
+
+    FileStatus dstFileStatus = null;
+    if (qualifiedSrcPath.equals(qualifiedDstPath)) {
+      // rename to itself
+      // - if it doesn't exist, return false
+      // - if it is file, return true
+      // - if it is dir, return false.
+      dstFileStatus = tryGetFileStatus(qualifiedDstPath);
+      if (dstFileStatus == null) {
+        return false;
+      }
+      return dstFileStatus.isDirectory() ? false : true;
+    }
+
+    // Non-HNS account need to check dst status on driver side.
+    if (!abfsStore.getIsNamespaceEnabled() && dstFileStatus == null) {
+      dstFileStatus = tryGetFileStatus(qualifiedDstPath);
+    }
 
-    final FileStatus dstFileStatus = tryGetFileStatus(dst);
     try {
       String sourceFileName = src.getName();
       Path adjustedDst = dst;
 
       if (dstFileStatus != null) {
         if (!dstFileStatus.isDirectory()) {
-          return src.equals(dst);
+          return qualifiedSrcPath.equals(qualifiedDstPath);
         }
-
         adjustedDst = new Path(dst, sourceFileName);
       }
 
-      Path qualifiedSrcPath = makeQualified(src);
-      Path qualifiedDstPath = makeQualified(adjustedDst);
+      qualifiedDstPath = makeQualified(adjustedDst);
       performAbfsAuthCheck(FsAction.READ_WRITE, qualifiedSrcPath, qualifiedDstPath);
 
       abfsStore.rename(qualifiedSrcPath, qualifiedDstPath);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message