HADOOP-16578 : Avoid FileSystem API calls when FileSystem already exists
This commit is contained in:
parent
ab7181e9af
commit
2ccb1683ba
@ -55,6 +55,7 @@
|
|||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.PathIOException;
|
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.FileSystemConfigurations;
|
||||||
import org.apache.hadoop.fs.azurebfs.constants.FileSystemUriSchemes;
|
import org.apache.hadoop.fs.azurebfs.constants.FileSystemUriSchemes;
|
||||||
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException;
|
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException;
|
||||||
@ -107,7 +108,7 @@ public void initialize(URI uri, Configuration configuration)
|
|||||||
this.setWorkingDirectory(this.getHomeDirectory());
|
this.setWorkingDirectory(this.getHomeDirectory());
|
||||||
|
|
||||||
if (abfsConfiguration.getCreateRemoteFileSystemDuringInitialization()) {
|
if (abfsConfiguration.getCreateRemoteFileSystemDuringInitialization()) {
|
||||||
if (!this.fileSystemExists()) {
|
if (this.tryGetFileStatus(new Path(AbfsHttpConstants.ROOT_PATH)) == null) {
|
||||||
try {
|
try {
|
||||||
this.createFileSystem();
|
this.createFileSystem();
|
||||||
} catch (AzureBlobFileSystemException ex) {
|
} catch (AzureBlobFileSystemException ex) {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.hadoop.fs.azurebfs;
|
package org.apache.hadoop.fs.azurebfs;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -25,6 +26,7 @@
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
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.contracts.exceptions.AbfsRestOperationException;
|
||||||
import org.apache.hadoop.fs.azurebfs.services.AuthType;
|
import org.apache.hadoop.fs.azurebfs.services.AuthType;
|
||||||
|
|
||||||
@ -68,12 +70,12 @@ public void testFailedRequestWhenFSNotExist() throws Exception {
|
|||||||
+ testUri.substring(testUri.indexOf("@"));
|
+ testUri.substring(testUri.indexOf("@"));
|
||||||
final AzureBlobFileSystem fs = this.getFileSystem(nonExistingFsUrl);
|
final AzureBlobFileSystem fs = this.getFileSystem(nonExistingFsUrl);
|
||||||
|
|
||||||
intercept(AbfsRestOperationException.class,
|
intercept(FileNotFoundException.class,
|
||||||
"\"The specified filesystem does not exist.\", 404",
|
"\"The specified filesystem does not exist.\", 404",
|
||||||
new LambdaTestUtils.VoidCallable() {
|
new LambdaTestUtils.VoidCallable() {
|
||||||
@Override
|
@Override
|
||||||
public void call() throws Exception {
|
public void call() throws Exception {
|
||||||
fs.getIsNamespaceEnabled();
|
fs.getFileStatus(new Path("/")); // Run a dummy FS call
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user