-
Notifications
You must be signed in to change notification settings - Fork 863
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
External names used for retry modes only support 'adaptive' #5265
Merged
sugmanue
merged 5 commits into
feature/master/sra-retries
from
sugmanue/resolver-for-adaptive
Jun 5, 2024
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
be570db
Externally named retry modes only support 'adaptive'
sugmanue 48e61cc
Sneak in a fix from the previous PR
sugmanue fb34e35
Fix a test that expects adaptive to map to `RetryMode.ADAPTIVE`
sugmanue 3751fed
Fix typo
sugmanue cb8b5cd
Fix typo
sugmanue 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -94,7 +94,7 @@ private void setupRetryPolicy(BuilderT builder, RetryScenario scenario) { | |
RetryModeSetup setup = scenario.setup(); | ||
switch (setup) { | ||
case PROFILE_USING_MODE: | ||
setupProfile(builder, scenario.mode()); | ||
setupProfile(builder, scenario); | ||
break; | ||
case CLIENT_OVERRIDE_USING_MODE: | ||
builder.overrideConfiguration(o -> o.retryPolicy(mode)); | ||
|
@@ -115,7 +115,7 @@ private void setupRetryStrategy(BuilderT builder, RetryScenario scenario) { | |
// client. | ||
switch (scenario.setup()) { | ||
case PROFILE_USING_MODE: | ||
setupProfile(builder, scenario.mode()); | ||
setupProfile(builder, scenario); | ||
break; | ||
case CLIENT_OVERRIDE_USING_MODE: | ||
builder.overrideConfiguration(o -> o.retryStrategy(mode)); | ||
|
@@ -130,8 +130,8 @@ private void setupRetryStrategy(BuilderT builder, RetryScenario scenario) { | |
} | ||
} | ||
|
||
private void setupProfile(BuilderT builder, RetryMode mode) { | ||
String modeName = mode.toString().toLowerCase(Locale.ROOT); | ||
private void setupProfile(BuilderT builder, RetryScenario scenario) { | ||
String modeName = scenario.modeExternalName(); | ||
ProfileFile profileFile = ProfileFile.builder() | ||
.content(new StringInputStream("[profile retry_test]\n" + | ||
"retry_mode = " + modeName)) | ||
|
@@ -165,7 +165,7 @@ private BuilderT clientBuilder() { | |
|
||
private void setupScenarioBefore(RetryScenario scenario) { | ||
if (scenario.setup() == RetryModeSetup.SYSTEM_PROPERTY_USING_MODE) { | ||
System.setProperty("aws.retryMode", scenario.mode().name().toLowerCase(Locale.ROOT)); | ||
System.setProperty("aws.retryMode", scenario.modeExternalName()); | ||
} | ||
} | ||
|
||
|
@@ -236,6 +236,16 @@ private static boolean isSupportedScenario(RetryScenario scenario) { | |
return false; | ||
} | ||
|
||
// System property or profile do not support the internal "adaptive_v2" name, only adaptive, | ||
// and it's mapped to adaptive_v2. We mark here adaptive using profile or system property | ||
// and map in te tests "adaptive_v2" to "adaptive" such that everything comes together at | ||
sugmanue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// the end. | ||
if (scenario.mode() == RetryMode.ADAPTIVE | ||
&& (scenario.setup() == RetryModeSetup.PROFILE_USING_MODE | ||
|| scenario.setup() == RetryModeSetup.SYSTEM_PROPERTY_USING_MODE)) { | ||
return false; | ||
} | ||
|
||
// Retry policies only support the legacy ADAPTIVE mode. | ||
if (scenario.retryImplementation() == RetryImplementation.POLICY | ||
&& scenario.mode() == RetryMode.ADAPTIVE_V2) { | ||
|
@@ -323,6 +333,25 @@ public Builder toBuilder() { | |
return new Builder(this); | ||
} | ||
|
||
/** | ||
* Returns the name used externally of the given mode. This name is used in the profile `retry_mode` setting or in the | ||
* system property. Externally, "adaptive" gets mapped to RetryMode.ADAPTIVE_V2, and "adaptive_v2" an internal name | ||
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. nit: "adaptive_v2" is an internal name
sugmanue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* only and not supported externally. | ||
*/ | ||
public String modeExternalName() { | ||
switch (mode) { | ||
case ADAPTIVE: | ||
case ADAPTIVE_V2: | ||
return "adaptive"; | ||
case LEGACY: | ||
return "legacy"; | ||
case STANDARD: | ||
return "standard"; | ||
default: | ||
throw new RuntimeException("Unsupported mode: " + mode); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return mode + " " + retryImplementation + " " + setup; | ||
|
Oops, something went wrong.
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.
nit: map in the tests