-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-19595. ABFS: AbfsConfiguration should store account type information (HNS or FNS) #7765
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
Changes from 1 commit
37d6a1e
179a18e
8e13f7b
ad210ef
fd0d14e
fa95fcf
71c8148
c4703b2
67c1562
5eb0616
6032492
ef93413
0b909fd
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 |
|---|---|---|
|
|
@@ -95,6 +95,7 @@ public class AbfsConfiguration{ | |
| private final AbfsServiceType fsConfiguredServiceType; | ||
| private final boolean isSecure; | ||
| private static final Logger LOG = LoggerFactory.getLogger(AbfsConfiguration.class); | ||
| private Trilean isNamespaceEnabled = null; | ||
|
|
||
| @StringConfigurationValidatorAnnotation(ConfigurationKey = FS_AZURE_ACCOUNT_IS_HNS_ENABLED, | ||
| DefaultValue = DEFAULT_FS_AZURE_ACCOUNT_IS_HNS_ENABLED) | ||
|
|
@@ -525,8 +526,11 @@ public AbfsConfiguration(final Configuration rawConfig, String accountName) | |
| * @return TRUE/FALSE value if configured, UNKNOWN if not configured. | ||
| */ | ||
| public Trilean getIsNamespaceEnabledAccount() { | ||
| return Trilean.getTrilean( | ||
| getString(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, isNamespaceEnabledAccount)); | ||
| if (isNamespaceEnabled == null) { | ||
| isNamespaceEnabled = Trilean.getTrilean( | ||
| getString(FS_AZURE_ACCOUNT_IS_HNS_ENABLED, isNamespaceEnabledAccount)); | ||
| } | ||
| return isNamespaceEnabled; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1525,8 +1529,8 @@ void setMaxBackoffIntervalMilliseconds(int maxBackoffInterval) { | |
| } | ||
|
|
||
| @VisibleForTesting | ||
| void setIsNamespaceEnabledAccount(String isNamespaceEnabledAccount) { | ||
| this.isNamespaceEnabledAccount = isNamespaceEnabledAccount; | ||
| public void setIsNamespaceEnabledAccount(Trilean isNamespaceEnabledAccount) { | ||
| isNamespaceEnabled = isNamespaceEnabledAccount; | ||
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -186,7 +186,6 @@ public class AzureBlobFileSystemStore implements Closeable, ListingSupport { | |
|
|
||
| private final AbfsConfiguration abfsConfiguration; | ||
| private Set<String> azureInfiniteLeaseDirSet; | ||
| private volatile Trilean isNamespaceEnabled; | ||
| private final AuthType authType; | ||
| private final UserGroupInformation userGroupInformation; | ||
| private final IdentityTransformerInterface identityTransformer; | ||
|
|
@@ -234,8 +233,6 @@ public AzureBlobFileSystemStore( | |
|
|
||
| LOG.trace("AbfsConfiguration init complete"); | ||
|
|
||
| this.isNamespaceEnabled = abfsConfiguration.getIsNamespaceEnabledAccount(); | ||
|
|
||
| this.userGroupInformation = UserGroupInformation.getCurrentUser(); | ||
| this.userName = userGroupInformation.getShortUserName(); | ||
| LOG.trace("UGI init complete"); | ||
|
|
@@ -287,18 +284,6 @@ public AzureBlobFileSystemStore( | |
| "abfs-bounded"); | ||
| } | ||
|
|
||
| /** | ||
| * Updates the client with the namespace information. | ||
| * | ||
| * @param tracingContext the tracing context to be used for the operation | ||
| * @throws AzureBlobFileSystemException if an error occurs while updating the client | ||
| */ | ||
| public void updateClientWithNamespaceInfo(TracingContext tracingContext) | ||
| throws AzureBlobFileSystemException { | ||
| boolean isNamespaceEnabled = getIsNamespaceEnabled(tracingContext); | ||
| AbfsClient.setIsNamespaceEnabled(isNamespaceEnabled); | ||
| } | ||
|
|
||
| /** | ||
| * Checks if the given key in Azure Storage should be stored as a page | ||
| * blob instead of block blob. | ||
|
|
@@ -409,32 +394,32 @@ public boolean getIsNamespaceEnabled(TracingContext tracingContext) | |
|
|
||
| private synchronized boolean getNamespaceEnabledInformationFromServer( | ||
| final TracingContext tracingContext) throws AzureBlobFileSystemException { | ||
| if (isNamespaceEnabled != Trilean.UNKNOWN) { | ||
| return isNamespaceEnabled.toBoolean(); | ||
| if (abfsConfiguration.getIsNamespaceEnabledAccount() != Trilean.UNKNOWN) { | ||
| return isNamespaceEnabled(); | ||
| } | ||
| try { | ||
| LOG.debug("Get root ACL status"); | ||
| getClient(AbfsServiceType.DFS).getAclStatus(AbfsHttpConstants.ROOT_PATH, tracingContext); | ||
| // If getAcl succeeds, namespace is enabled. | ||
| isNamespaceEnabled = Trilean.getTrilean(true); | ||
| setNamespaceEnabled(Trilean.TRUE); | ||
| } catch (AbfsRestOperationException ex) { | ||
| // Get ACL status is a HEAD request, its response doesn't contain errorCode | ||
| // So can only rely on its status code to determine account type. | ||
| if (HttpURLConnection.HTTP_BAD_REQUEST != ex.getStatusCode()) { | ||
| // If getAcl fails with anything other than 400, namespace is enabled. | ||
| isNamespaceEnabled = Trilean.getTrilean(true); | ||
| setNamespaceEnabled(Trilean.TRUE); | ||
| // Continue to throw exception as earlier. | ||
| LOG.debug("Failed to get ACL status with non 400. Inferring namespace enabled", ex); | ||
| throw ex; | ||
| } | ||
| // If getAcl fails with 400, namespace is disabled. | ||
| LOG.debug("Failed to get ACL status with 400. " | ||
| + "Inferring namespace disabled and ignoring error", ex); | ||
| isNamespaceEnabled = Trilean.getTrilean(false); | ||
| setNamespaceEnabled(Trilean.FALSE); | ||
| } catch (AzureBlobFileSystemException ex) { | ||
| throw ex; | ||
| } | ||
| return isNamespaceEnabled.toBoolean(); | ||
| return isNamespaceEnabled(); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -443,7 +428,7 @@ private synchronized boolean getNamespaceEnabledInformationFromServer( | |
| */ | ||
| @VisibleForTesting | ||
| boolean isNamespaceEnabled() throws TrileanConversionException { | ||
| return this.isNamespaceEnabled.toBoolean(); | ||
| return abfsConfiguration.getIsNamespaceEnabledAccount().toBoolean(); | ||
|
||
| } | ||
|
|
||
| @VisibleForTesting | ||
|
|
@@ -2028,7 +2013,7 @@ DataBlocks.BlockFactory getBlockFactory() { | |
|
|
||
| @VisibleForTesting | ||
| void setNamespaceEnabled(Trilean isNamespaceEnabled){ | ||
| this.isNamespaceEnabled = isNamespaceEnabled; | ||
| abfsConfiguration.setIsNamespaceEnabledAccount(isNamespaceEnabled); | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,7 @@ | |
| import org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidFileSystemPropertyException; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.exceptions.InvalidUriException; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.exceptions.SASTokenProviderException; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.exceptions.TrileanConversionException; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.services.AppendRequestParameters; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.services.AzureServiceErrorCode; | ||
| import org.apache.hadoop.fs.azurebfs.contracts.services.ListResultEntrySchema; | ||
|
|
@@ -194,7 +195,6 @@ | |
| private KeepAliveCache keepAliveCache; | ||
|
|
||
| private AbfsApacheHttpClient abfsApacheHttpClient; | ||
| private static boolean isNamespaceEnabled = false; | ||
|
|
||
| /** | ||
| * logging the rename failure if metadata is in an incomplete state. | ||
|
|
@@ -1717,17 +1717,13 @@ | |
| * | ||
| * @return True if the namespace is enabled, false otherwise. | ||
| */ | ||
| public static boolean getIsNamespaceEnabled() { | ||
| return isNamespaceEnabled; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the namespace enabled status. | ||
| * | ||
| * @param namespaceEnabled True to enable the namespace, false to disable it. | ||
| */ | ||
| public static void setIsNamespaceEnabled(final boolean namespaceEnabled) { | ||
| isNamespaceEnabled = namespaceEnabled; | ||
| public boolean getIsNamespaceEnabled() throws TrileanConversionException { | ||
|
Check failure on line 1720 in hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsClient.java
|
||
| try { | ||
| return abfsConfiguration.getIsNamespaceEnabledAccount().toBoolean(); | ||
| } catch (TrileanConversionException ex) { | ||
| LOG.error("Failed to convert namespace enabled account property to boolean", ex); | ||
| throw ex; | ||
| } | ||
| } | ||
|
|
||
| protected boolean isRenameResilience() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1565,7 +1565,8 @@ | |
| * @return client transaction id | ||
| */ | ||
| @VisibleForTesting | ||
| public String addClientTransactionIdToHeader(List<AbfsHttpHeader> requestHeaders) { | ||
| public String addClientTransactionIdToHeader(List<AbfsHttpHeader> requestHeaders) | ||
|
Check failure on line 1568 in hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsDfsClient.java
|
||
| throws AzureBlobFileSystemException{ | ||
| String clientTransactionId = null; | ||
| // Set client transaction ID if the namespace and client transaction ID config are enabled. | ||
| if (getIsNamespaceEnabled() && getAbfsConfiguration().getIsClientTransactionIdEnabled()) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be setting this value on abfsconfiguration object only when we know the exact value. Do we really need this to be Trilean? I think we should pass the definitive argument and do the Boolean to Trilean conversion here just to make sure that no one accidently sets UNKNOWN here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense, made changes accordingly.