HADOOP-15940. ABFS: For HNS account, avoid unnecessary get call when doing Rename.
Contributed by Da Zhou <da.zhou@microsoft.com>
This commit is contained in:
parent
2e6b9b174e
commit
1a3a4960d9
|
@ -271,22 +271,44 @@ public class AzureBlobFileSystem extends FileSystem {
|
||||||
if (parentFolder == null) {
|
if (parentFolder == null) {
|
||||||
return false;
|
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 {
|
try {
|
||||||
String sourceFileName = src.getName();
|
String sourceFileName = src.getName();
|
||||||
Path adjustedDst = dst;
|
Path adjustedDst = dst;
|
||||||
|
|
||||||
if (dstFileStatus != null) {
|
if (dstFileStatus != null) {
|
||||||
if (!dstFileStatus.isDirectory()) {
|
if (!dstFileStatus.isDirectory()) {
|
||||||
return src.equals(dst);
|
return qualifiedSrcPath.equals(qualifiedDstPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustedDst = new Path(dst, sourceFileName);
|
adjustedDst = new Path(dst, sourceFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Path qualifiedSrcPath = makeQualified(src);
|
qualifiedDstPath = makeQualified(adjustedDst);
|
||||||
Path qualifiedDstPath = makeQualified(adjustedDst);
|
|
||||||
performAbfsAuthCheck(FsAction.READ_WRITE, qualifiedSrcPath, qualifiedDstPath);
|
performAbfsAuthCheck(FsAction.READ_WRITE, qualifiedSrcPath, qualifiedDstPath);
|
||||||
|
|
||||||
abfsStore.rename(qualifiedSrcPath, qualifiedDstPath);
|
abfsStore.rename(qualifiedSrcPath, qualifiedDstPath);
|
||||||
|
|
Loading…
Reference in New Issue