-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HADOOP-17811: ABFS ExponentialRetryPolicy doesn't pick up configuration values #3221
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 all commits
1b65fd3
2e746c9
cc766d3
6fa0597
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 |
---|---|---|
|
@@ -18,6 +18,11 @@ | |
|
||
package org.apache.hadoop.fs.azurebfs.services; | ||
|
||
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_BACKOFF_INTERVAL; | ||
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_MAX_BACKOFF_INTERVAL; | ||
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_MAX_IO_RETRIES; | ||
import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_MIN_BACKOFF_INTERVAL; | ||
|
||
import java.util.Random; | ||
|
||
import org.junit.Assert; | ||
|
@@ -32,7 +37,6 @@ | |
* Unit test TestExponentialRetryPolicy. | ||
*/ | ||
public class TestExponentialRetryPolicy extends AbstractAbfsIntegrationTest { | ||
|
||
private final int maxRetryCount = 30; | ||
private final int noRetryCount = 0; | ||
private final int retryCount = new Random().nextInt(maxRetryCount); | ||
|
@@ -57,12 +61,38 @@ public void testDifferentMaxIORetryCount() throws Exception { | |
@Test | ||
public void testDefaultMaxIORetryCount() throws Exception { | ||
AbfsConfiguration abfsConfig = getAbfsConfig(); | ||
Assert.assertTrue( | ||
Assert.assertEquals( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you use AssertJ.assertThat() you can use its describedAs for sprintf-style formatting. We're embracing that for new code and more complex assertions, so don't be afraid to use it here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I only changed this line because my IDE was warning me about it--it's not otherwise relevant to my change. I looked at doing what you suggested and unfortunately the assertj version of assertThat cannot be statically imported since there are assertThat methods on the base class that the test extends. Given that, I think this change would make the code less readable. |
||
String.format("default maxIORetry count is %s.", maxRetryCount), | ||
abfsConfig.getMaxIoRetries() == maxRetryCount); | ||
maxRetryCount, abfsConfig.getMaxIoRetries()); | ||
testMaxIOConfig(abfsConfig); | ||
} | ||
|
||
@Test | ||
public void testAbfsConfigConstructor() throws Exception { | ||
// Ensure we choose expected values that are not defaults | ||
ExponentialRetryPolicy template = new ExponentialRetryPolicy( | ||
getAbfsConfig().getMaxIoRetries()); | ||
int testModifier = 1; | ||
int expectedMaxRetries = template.getRetryCount() + testModifier; | ||
int expectedMinBackoff = template.getMinBackoff() + testModifier; | ||
int expectedMaxBackoff = template.getMaxBackoff() + testModifier; | ||
int expectedDeltaBackoff = template.getDeltaBackoff() + testModifier; | ||
|
||
Configuration config = new Configuration(this.getRawConfiguration()); | ||
config.setInt(AZURE_MAX_IO_RETRIES, expectedMaxRetries); | ||
config.setInt(AZURE_MIN_BACKOFF_INTERVAL, expectedMinBackoff); | ||
config.setInt(AZURE_MAX_BACKOFF_INTERVAL, expectedMaxBackoff); | ||
config.setInt(AZURE_BACKOFF_INTERVAL, expectedDeltaBackoff); | ||
|
||
ExponentialRetryPolicy policy = new ExponentialRetryPolicy( | ||
new AbfsConfiguration(config, "dummyAccountName")); | ||
|
||
Assert.assertEquals("Max retry count was not set as expected.", expectedMaxRetries, policy.getRetryCount()); | ||
Assert.assertEquals("Min backoff interval was not set as expected.", expectedMinBackoff, policy.getMinBackoff()); | ||
Assert.assertEquals("Max backoff interval was not set as expected.", expectedMaxBackoff, policy.getMaxBackoff()); | ||
Assert.assertEquals("Delta backoff interval was not set as expected.", expectedDeltaBackoff, policy.getDeltaBackoff()); | ||
} | ||
|
||
private AbfsConfiguration getAbfsConfig() throws Exception { | ||
Configuration | ||
config = new Configuration(this.getRawConfiguration()); | ||
|
@@ -81,8 +111,8 @@ private void testMaxIOConfig(AbfsConfiguration abfsConfig) { | |
localRetryCount++; | ||
} | ||
|
||
Assert.assertTrue( | ||
Assert.assertEquals( | ||
"When all retries are exhausted, the retryCount will be same as max configured", | ||
localRetryCount == abfsConfig.getMaxIoRetries()); | ||
abfsConfig.getMaxIoRetries(), localRetryCount); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.