From e0260417ade5568ae37dcc3753aea0d1e0fd701b Mon Sep 17 00:00:00 2001 From: Da Zhou Date: Fri, 8 Mar 2019 13:53:08 +0000 Subject: [PATCH] HADOOP-16169. ABFS: Bug fix for getPathProperties. Author: Da Zhou --- .../hadoop/fs/azurebfs/AzureBlobFileSystemStore.java | 12 ++++++------ .../hadoop/fs/azurebfs/services/AbfsClient.java | 4 ++-- .../fs/azurebfs/ITestFileSystemProperties.java | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java index f8360432ad..a8e0ed3ef0 100644 --- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java +++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystemStore.java @@ -284,13 +284,13 @@ public void setFilesystemProperties(final Hashtable properties) client.setFilesystemProperties(commaSeparatedProperties); } - public Hashtable getPathProperties(final Path path) throws AzureBlobFileSystemException { - LOG.debug("getPathProperties for filesystem: {} path: {}", + public Hashtable getPathStatus(final Path path) throws AzureBlobFileSystemException { + LOG.debug("getPathStatus for filesystem: {} path: {}", client.getFileSystem(), path); final Hashtable parsedXmsProperties; - final AbfsRestOperation op = client.getPathProperties(AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path), isNamespaceEnabled); + final AbfsRestOperation op = client.getPathStatus(AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path)); final String xMsProperties = op.getResult().getResponseHeader(HttpHeaderConfigurations.X_MS_PROPERTIES); @@ -372,7 +372,7 @@ public AbfsInputStream openFileForRead(final Path path, final FileSystem.Statist client.getFileSystem(), path); - final AbfsRestOperation op = client.getPathProperties(AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path), isNamespaceEnabled); + final AbfsRestOperation op = client.getPathStatus(AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path)); final String resourceType = op.getResult().getResponseHeader(HttpHeaderConfigurations.X_MS_RESOURCE_TYPE); final long contentLength = Long.parseLong(op.getResult().getResponseHeader(HttpHeaderConfigurations.CONTENT_LENGTH)); @@ -400,7 +400,7 @@ public OutputStream openFileForWrite(final Path path, final boolean overwrite) t path, overwrite); - final AbfsRestOperation op = client.getPathProperties(AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path), isNamespaceEnabled); + final AbfsRestOperation op = client.getPathStatus(AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path)); final String resourceType = op.getResult().getResponseHeader(HttpHeaderConfigurations.X_MS_RESOURCE_TYPE); final Long contentLength = Long.valueOf(op.getResult().getResponseHeader(HttpHeaderConfigurations.CONTENT_LENGTH)); @@ -476,7 +476,7 @@ public FileStatus getFileStatus(final Path path) throws IOException { ? client.getAclStatus(AbfsHttpConstants.FORWARD_SLASH + AbfsHttpConstants.ROOT_PATH) : client.getFilesystemProperties(); } else { - op = client.getPathProperties(AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path), isNamespaceEnabled); + op = client.getPathStatus(AbfsHttpConstants.FORWARD_SLASH + getRelativePath(path)); } final long blockSize = abfsConfiguration.getAzureBlockSize(); diff --git a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java index ea665bd1f6..c634c35e16 100644 --- a/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java +++ b/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java @@ -348,7 +348,7 @@ public AbfsRestOperation setPathProperties(final String path, final String prope return op; } - public AbfsRestOperation getPathProperties(final String path, boolean isNameSpaceEnabled) throws AzureBlobFileSystemException { + public AbfsRestOperation getPathStatus(final String path) throws AzureBlobFileSystemException { final List requestHeaders = createDefaultHeaders(); final AbfsUriQueryBuilder abfsUriQueryBuilder = createDefaultUriQueryBuilder(); @@ -356,7 +356,7 @@ public AbfsRestOperation getPathProperties(final String path, boolean isNameSpac final URL url = createRequestUrl(path, abfsUriQueryBuilder.toString()); final AbfsRestOperation op = new AbfsRestOperation( - isNameSpaceEnabled ? AbfsRestOperationType.GetPathProperties : AbfsRestOperationType.GetPathStatus, + AbfsRestOperationType.GetPathStatus, this, HTTP_METHOD_HEAD, url, diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestFileSystemProperties.java b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestFileSystemProperties.java index e6b45c8f8b..ba9b639adb 100644 --- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestFileSystemProperties.java +++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestFileSystemProperties.java @@ -78,7 +78,7 @@ public void testBase64PathProperties() throws Exception { touch(TEST_PATH); fs.getAbfsStore().setPathProperties(TEST_PATH, properties); Hashtable fetchedProperties = - fs.getAbfsStore().getPathProperties(TEST_PATH); + fs.getAbfsStore().getPathStatus(TEST_PATH); assertEquals(properties, fetchedProperties); } @@ -101,7 +101,7 @@ public void testBase64InvalidPathProperties() throws Exception { properties.put("key", "{ value: valueTestå…© }"); touch(TEST_PATH); fs.getAbfsStore().setPathProperties(TEST_PATH, properties); - Hashtable fetchedProperties = fs.getAbfsStore().getPathProperties(TEST_PATH); + Hashtable fetchedProperties = fs.getAbfsStore().getPathStatus(TEST_PATH); assertEquals(properties, fetchedProperties); }