HADOOP-16578 : Avoid FileSystem API calls when FileSystem already exists

This commit is contained in:
Sneha Vijayarajan 2019-10-01 17:38:11 -07:00 committed by DadanielZ
parent d947ded053
commit 770adc5d4a
No known key found for this signature in database
GPG Key ID: 5C91E270F172ADFB
2 changed files with 6 additions and 3 deletions

View File

@ -56,6 +56,7 @@ import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathIOException;
import org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants;
import org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations;
import org.apache.hadoop.fs.azurebfs.constants.FileSystemUriSchemes;
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException;
@ -111,7 +112,7 @@ public class AzureBlobFileSystem extends FileSystem {
this.setWorkingDirectory(this.getHomeDirectory());
if (abfsConfiguration.getCreateRemoteFileSystemDuringInitialization()) {
if (!this.fileSystemExists()) {
if (this.tryGetFileStatus(new Path(AbfsHttpConstants.ROOT_PATH)) == null) {
try {
this.createFileSystem();
} catch (AzureBlobFileSystemException ex) {

View File

@ -17,6 +17,7 @@
*/
package org.apache.hadoop.fs.azurebfs;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.UUID;
@ -24,6 +25,7 @@ import org.junit.Assume;
import org.junit.Test;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException;
import org.apache.hadoop.fs.azurebfs.services.AuthType;
@ -67,10 +69,10 @@ public class ITestGetNameSpaceEnabled extends AbstractAbfsIntegrationTest {
+ testUri.substring(testUri.indexOf("@"));
AzureBlobFileSystem fs = this.getFileSystem(nonExistingFsUrl);
intercept(AbfsRestOperationException.class,
intercept(FileNotFoundException.class,
"\"The specified filesystem does not exist.\", 404",
()-> {
fs.getIsNamespaceEnabled();
fs.getFileStatus(new Path("/")); // Run a dummy FS call
});
}