-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HADOOP-19284: [ABFS] Allow "fs.azure.account.hns.enabled" to be set as Account Specific Config #7062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HADOOP-19284: [ABFS] Allow "fs.azure.account.hns.enabled" to be set as Account Specific Config #7062
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,8 +450,17 @@ public AbfsConfiguration(final Configuration rawConfig, String accountName) | |
this(rawConfig, accountName, AbfsServiceType.DFS); | ||
} | ||
|
||
/** | ||
* Returns the account type as per the user configuration. Gets the account | ||
* specific value if it exists, then looks for an account agnostic value. | ||
* If not configured driver makes additional getAcl call to determine | ||
* the account type during file system initialization. | ||
* @return TRUE/FALSE value if configured, UNKNOWN if not configured. | ||
*/ | ||
public Trilean getIsNamespaceEnabledAccount() { | ||
return Trilean.getTrilean(isNamespaceEnabledAccount); | ||
String isNamespaceEnabledAccountString | ||
= getString(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, isNamespaceEnabledAccount); | ||
return Trilean.getTrilean(isNamespaceEnabledAccountString); | ||
|
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
|
||
import org.apache.hadoop.fs.CommonConfigurationKeysPublic; | ||
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.azurebfs.constants.AbfsServiceType; | ||
import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException; | ||
import org.apache.hadoop.fs.azurebfs.services.AbfsClient; | ||
import org.apache.hadoop.fs.azurebfs.services.AbfsDfsClient; | ||
|
@@ -41,6 +42,7 @@ | |
import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR; | ||
import static java.net.HttpURLConnection.HTTP_NOT_FOUND; | ||
import static java.net.HttpURLConnection.HTTP_UNAVAILABLE; | ||
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.accountProperty; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.Mockito.doReturn; | ||
|
@@ -126,6 +128,8 @@ private AzureBlobFileSystem getNewFSWithHnsConf( | |
Configuration rawConfig = new Configuration(); | ||
rawConfig.addResource(TEST_CONFIGURATION_FILE_NAME); | ||
rawConfig.set(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, isNamespaceEnabledAccount); | ||
rawConfig.set(accountProperty(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, | ||
this.getAccountName()), isNamespaceEnabledAccount); | ||
rawConfig | ||
.setBoolean(AZURE_CREATE_REMOTE_FILESYSTEM_DURING_INITIALIZATION, true); | ||
rawConfig.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, | ||
|
@@ -247,7 +251,7 @@ private void ensureGetAclDetermineHnsStatusAccuratelyInternal(int statusCode, | |
AzureBlobFileSystemStore store = Mockito.spy(getFileSystem().getAbfsStore()); | ||
AbfsClient mockClient = mock(AbfsClient.class); | ||
store.setNamespaceEnabled(Trilean.UNKNOWN); | ||
doReturn(mockClient).when(store).getClient(); | ||
doReturn(mockClient).when(store).getClient(AbfsServiceType.DFS); | ||
AbfsRestOperationException ex = new AbfsRestOperationException( | ||
statusCode, null, Integer.toString(statusCode), null); | ||
doThrow(ex).when(mockClient).getAclStatus(anyString(), any(TracingContext.class)); | ||
|
@@ -271,4 +275,52 @@ private void ensureGetAclDetermineHnsStatusAccuratelyInternal(int statusCode, | |
Mockito.verify(mockClient, times(1)) | ||
.getAclStatus(anyString(), any(TracingContext.class)); | ||
} | ||
|
||
@Test | ||
public void testAccountSpecificConfig() throws Exception { | ||
Configuration rawConfig = new Configuration(); | ||
rawConfig.addResource(TEST_CONFIGURATION_FILE_NAME); | ||
rawConfig.unset(FS_AZURE_ACCOUNT_IS_HNS_ENABLED); | ||
rawConfig.unset(accountProperty(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, | ||
this.getAccountName())); | ||
String accountName1 = "account1.dfs.core.windows.net"; | ||
String accountName2 = "account2.dfs.core.windows.net"; | ||
String accountName3 = "account3.dfs.core.windows.net"; | ||
String defaultUri1 = this.getTestUrl().replace(this.getAccountName(), accountName1); | ||
String defaultUri2 = this.getTestUrl().replace(this.getAccountName(), accountName2); | ||
String defaultUri3 = this.getTestUrl().replace(this.getAccountName(), accountName3); | ||
|
||
// Set both account specific and account agnostic config for account 1 | ||
rawConfig.set(accountProperty(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, accountName1), FALSE_STR); | ||
rawConfig.set(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, TRUE_STR); | ||
rawConfig.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, defaultUri1); | ||
AzureBlobFileSystem fs1 = (AzureBlobFileSystem) FileSystem.newInstance(rawConfig); | ||
surendralilhore marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// Assert that account specific config takes precedence | ||
Assertions.assertThat(getIsNamespaceEnabled(fs1)).describedAs( | ||
"getIsNamespaceEnabled should return true when the " | ||
+ "account specific config is set as true").isFalse(); | ||
|
||
// Set only the account specific config for account 2 | ||
rawConfig.set(accountProperty(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, accountName2), FALSE_STR); | ||
rawConfig.unset(FS_AZURE_ACCOUNT_IS_HNS_ENABLED); | ||
rawConfig.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, defaultUri2); | ||
AzureBlobFileSystem fs2 = (AzureBlobFileSystem) FileSystem.newInstance(rawConfig); | ||
// Assert that account specific config is enough. | ||
Assertions.assertThat(getIsNamespaceEnabled(fs2)).describedAs( | ||
"getIsNamespaceEnabled should return true when the " | ||
+ "account specific config is set as true").isFalse(); | ||
|
||
// Set only account agnostic config for account 3 | ||
rawConfig.set(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, FALSE_STR); | ||
rawConfig.unset(accountProperty(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, accountName3)); | ||
rawConfig.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, defaultUri3); | ||
AzureBlobFileSystem fs3 = (AzureBlobFileSystem) FileSystem.newInstance(rawConfig); | ||
// Assert that account agnostic config is enough. | ||
Assertions.assertThat(getIsNamespaceEnabled(fs3)).describedAs( | ||
|
||
"getIsNamespaceEnabled should return true when the " | ||
+ "account specific config is not set").isFalse(); | ||
fs1.close(); | ||
fs2.close(); | ||
fs3.close(); | ||
surendralilhore marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
anujmodi2021 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Uh oh!
There was an error while loading. Please reload this page.