Skip to content

Refactor retry strategies #4039

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,15 @@ public void visit(Method method) {
}
} else if (isBuildable && method.getName().equals("toBuilder") && method.getSignature().startsWith("()")) {
// This is a buildable toBuilder
constructorsInvokedFromToBuilder.computeIfAbsent(getDottedClassName(), n -> new HashMap<>());
toBuilderModifiedFields.computeIfAbsent(getDottedClassName(), n -> new HashMap<>());
String dottedClassName = getDottedClassName();
constructorsInvokedFromToBuilder.computeIfAbsent(dottedClassName, n -> new HashMap<>());
toBuilderModifiedFields.computeIfAbsent(dottedClassName, n -> new HashMap<>());
inBuildableToBuilder = true;
inBuilderConstructor = false;

if (method.isAbstract()) {
// Ignore abstract toBuilder methods, we will still validate the actual implementations.
ignoredBuildables.add(dottedClassName);
}
registerIgnoredFields();
} else {
inBuildableToBuilder = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
* perceived availability for the clients to be close to 1.0.
*/
class AdaptiveRetryStrategyResourceConstrainedTest {
static final int DEFAULT_EXCEPTION_TOKEN_COST = 5;

@Test
void seemsToBeCorrectAndThreadSafe() {
Expand All @@ -61,12 +62,12 @@ void seemsToBeCorrectAndThreadSafe() {
int parallelism = serverWorkers + clientWorkers;
ExecutorService executor = Executors.newFixedThreadPool(parallelism);
Server server = new Server(serverWorkers, executor);
RateLimiterTokenBucketStore store = RateLimiterTokenBucketStore.builder().build();
AdaptiveRetryStrategy strategy = DefaultAdaptiveRetryStrategy
.builder()
// We don't care about how many attempts we allow to, that logic is tested somewhere else.
// so we give the strategy plenty of room for retries.
.maxAttempts(20)
.tokenBucketExceptionCost(DEFAULT_EXCEPTION_TOKEN_COST)
.tokenBucketStore(TokenBucketStore.builder().tokenBucketMaxCapacity(10_000).build())
// Just wait for the rate limiter delays.
.backoffStrategy(BackoffStrategy.retryImmediately())
Expand Down
Loading