-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HADOOP-17092. ABFS: Making AzureADAuthenticator.getToken() throw HttpException if a… #2123
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
Merged
DadanielZ
merged 10 commits into
apache:trunk
from
bilaharith:HADOOP-17092-gettokenretry
Jul 21, 2020
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dc0a35f
ABFS: Making AzureADAuthenticator.getToken() throw HttpException if a…
bilaharith 090410c
Made the retry policy configuarable
bilaharith 5911314
Fixing checkstyle issues
bilaharith 62d1f90
Fixing retry logic
bilaharith 6ac3ef8
Review comments incorporated
bilaharith 6ea50f0
Addressing review comments
bilaharith c72183f
Removing unnecessary formattings
bilaharith a6bc587
Incorporating changes for HADOOP-17093, prevents retries for unrecove…
bilaharith 2b1886b
Checkstyle fixes
bilaharith 0682b22
Merge branch 'trunk' into HADOOP-17092-gettokenretry
bilaharith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
...-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/TestAzureADAuthenticator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.hadoop.fs.azurebfs.services; | ||
|
||
import java.io.IOException; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.Test; | ||
|
||
import org.apache.hadoop.fs.azurebfs.AbfsConfiguration; | ||
import org.apache.hadoop.fs.azurebfs.AbstractAbfsIntegrationTest; | ||
|
||
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_OAUTH_TOKEN_FETCH_RETRY_COUNT; | ||
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_OAUTH_TOKEN_FETCH_RETRY_DELTA_BACKOFF; | ||
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_OAUTH_TOKEN_FETCH_RETRY_MAX_BACKOFF; | ||
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_OAUTH_TOKEN_FETCH_RETRY_MIN_BACKOFF; | ||
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_DELTA_BACKOFF; | ||
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_MAX_ATTEMPTS; | ||
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_MAX_BACKOFF_INTERVAL; | ||
import static org.apache.hadoop.fs.azurebfs.constants.FileSystemConfigurations.DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_MIN_BACKOFF_INTERVAL; | ||
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_ACCOUNT_NAME; | ||
|
||
public class TestAzureADAuthenticator extends AbstractAbfsIntegrationTest { | ||
|
||
private static final int TEST_RETRY_COUNT = 10; | ||
private static final int TEST_MIN_BACKOFF = 20; | ||
private static final int TEST_MAX_BACKOFF = 30; | ||
private static final int TEST_DELTA_BACKOFF = 40; | ||
|
||
public TestAzureADAuthenticator() throws Exception { | ||
super(); | ||
} | ||
|
||
@Test | ||
public void testDefaultOAuthTokenFetchRetryPolicy() throws Exception { | ||
getConfiguration().unset(AZURE_OAUTH_TOKEN_FETCH_RETRY_COUNT); | ||
getConfiguration().unset(AZURE_OAUTH_TOKEN_FETCH_RETRY_MIN_BACKOFF); | ||
getConfiguration().unset(AZURE_OAUTH_TOKEN_FETCH_RETRY_MAX_BACKOFF); | ||
getConfiguration().unset(AZURE_OAUTH_TOKEN_FETCH_RETRY_DELTA_BACKOFF); | ||
|
||
String accountName = getConfiguration().get(FS_AZURE_ACCOUNT_NAME); | ||
AbfsConfiguration abfsConfig = new AbfsConfiguration(getRawConfiguration(), | ||
accountName); | ||
|
||
ExponentialRetryPolicy retryPolicy = abfsConfig | ||
.getOauthTokenFetchRetryPolicy(); | ||
|
||
Assertions.assertThat(retryPolicy.getRetryCount()).describedAs( | ||
"retryCount should be the default value {} as the same " | ||
+ "is not configured", | ||
DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_MAX_ATTEMPTS) | ||
.isEqualTo(DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_MAX_ATTEMPTS); | ||
Assertions.assertThat(retryPolicy.getMinBackoff()).describedAs( | ||
"minBackOff should be the default value {} as the same is " | ||
+ "not configured", | ||
DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_MIN_BACKOFF_INTERVAL) | ||
.isEqualTo(DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_MIN_BACKOFF_INTERVAL); | ||
Assertions.assertThat(retryPolicy.getMaxBackoff()).describedAs( | ||
"maxBackOff should be the default value {} as the same is " | ||
+ "not configured", | ||
DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_MAX_BACKOFF_INTERVAL) | ||
.isEqualTo(DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_MAX_BACKOFF_INTERVAL); | ||
Assertions.assertThat(retryPolicy.getDeltaBackoff()).describedAs( | ||
"deltaBackOff should be the default value {} as the same " + "is " | ||
+ "not configured", | ||
DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_DELTA_BACKOFF) | ||
.isEqualTo(DEFAULT_AZURE_OAUTH_TOKEN_FETCH_RETRY_DELTA_BACKOFF); | ||
|
||
} | ||
|
||
@Test | ||
public void testOAuthTokenFetchRetryPolicy() | ||
throws IOException, IllegalAccessException { | ||
|
||
getConfiguration() | ||
.set(AZURE_OAUTH_TOKEN_FETCH_RETRY_COUNT, String.valueOf(TEST_RETRY_COUNT)); | ||
getConfiguration().set(AZURE_OAUTH_TOKEN_FETCH_RETRY_MIN_BACKOFF, | ||
String.valueOf(TEST_MIN_BACKOFF)); | ||
getConfiguration().set(AZURE_OAUTH_TOKEN_FETCH_RETRY_MAX_BACKOFF, | ||
String.valueOf(TEST_MAX_BACKOFF)); | ||
getConfiguration().set(AZURE_OAUTH_TOKEN_FETCH_RETRY_DELTA_BACKOFF, | ||
String.valueOf(TEST_DELTA_BACKOFF)); | ||
|
||
String accountName = getConfiguration().get(FS_AZURE_ACCOUNT_NAME); | ||
AbfsConfiguration abfsConfig = new AbfsConfiguration(getRawConfiguration(), | ||
accountName); | ||
|
||
ExponentialRetryPolicy retryPolicy = abfsConfig | ||
.getOauthTokenFetchRetryPolicy(); | ||
|
||
Assertions.assertThat(retryPolicy.getRetryCount()) | ||
.describedAs("retryCount should be {}", TEST_RETRY_COUNT) | ||
.isEqualTo(TEST_RETRY_COUNT); | ||
Assertions.assertThat(retryPolicy.getMinBackoff()) | ||
.describedAs("minBackOff should be {}", TEST_MIN_BACKOFF) | ||
.isEqualTo(TEST_MIN_BACKOFF); | ||
Assertions.assertThat(retryPolicy.getMaxBackoff()) | ||
.describedAs("maxBackOff should be {}", TEST_MAX_BACKOFF) | ||
.isEqualTo(TEST_MAX_BACKOFF); | ||
Assertions.assertThat(retryPolicy.getDeltaBackoff()) | ||
.describedAs("deltaBackOff should be {}", TEST_DELTA_BACKOFF) | ||
.isEqualTo(TEST_DELTA_BACKOFF); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As every OAuth token provider eventually calls this method to get token, you will just need to create an instance of exponential retry right here with the configured values ?
Is there any benefit creating and passing down exponential retry instance from each of the token provider ?
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.
Done
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.
Done