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
Make calls to endpoint discovery non-blocking for asynchornous clients #5205
Conversation
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.
Can we include the test we discussed offline for testing a client using Runnable::run
for FUTURE_COMPLETION_EXECUTOR
?
...c/main/java/software/amazon/awssdk/core/endpointdiscovery/EndpointDiscoveryRefreshCache.java
Outdated
Show resolved
Hide resolved
...c/main/java/software/amazon/awssdk/core/endpointdiscovery/EndpointDiscoveryRefreshCache.java
Show resolved
Hide resolved
...c/main/java/software/amazon/awssdk/core/endpointdiscovery/EndpointDiscoveryRefreshCache.java
Outdated
Show resolved
Hide resolved
...c/main/java/software/amazon/awssdk/core/endpointdiscovery/EndpointDiscoveryRefreshCache.java
Outdated
Show resolved
Hide resolved
...c/main/java/software/amazon/awssdk/core/endpointdiscovery/EndpointDiscoveryRefreshCache.java
Outdated
Show resolved
Hide resolved
...c/main/java/software/amazon/awssdk/core/endpointdiscovery/EndpointDiscoveryRefreshCache.java
Outdated
Show resolved
Hide resolved
...c/main/java/software/amazon/awssdk/core/endpointdiscovery/EndpointDiscoveryRefreshCache.java
Outdated
Show resolved
Hide resolved
@@ -193,12 +193,12 @@ public CompletableFuture<TestDiscoveryIdentifiersRequiredResponse> testDiscovery | |||
.overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider) | |||
.orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER)) | |||
.resolveIdentity(); | |||
endpointFuture = identityFuture.thenApply(credentials -> { | |||
endpointFuture = identityFuture.thenCompose(credentials -> { |
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.
Should we propagate exception cancellation? What happens if endpoint discovery takes longer than the configured client execution timeout? Would the request fail properly?
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.
hmm.. So the cancellation Exception is going to be thrown here
return discoverEndpoint(request).handle(
(endpointDiscoveryEndpoint, throwable) -> {
if (throwable != null) {
throw new RuntimeException(throwable);
This will be propogated upwards, unless you mean something else
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.
I am wrapping it around an EndpointDiscoveryFailedException
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.
I meant if users have client execution timeout enabled and if endpoint discovery takes longer than the configured timeout, the returned future will be cancelled, but will endpoint discovery future also be cancelled?
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.
I think we just need CompletableFutureUtils.forwardExceptionTo(executeFuture, endpointFuture );
on line 277.
Can we write a test to verify that?
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.
Discussed offline. Doing this as a follow up item
...c/main/java/software/amazon/awssdk/core/endpointdiscovery/EndpointDiscoveryRefreshCache.java
Outdated
Show resolved
Hide resolved
...c/main/java/software/amazon/awssdk/core/endpointdiscovery/EndpointDiscoveryRefreshCache.java
Outdated
Show resolved
Hide resolved
...c/main/java/software/amazon/awssdk/core/endpointdiscovery/EndpointDiscoveryRefreshCache.java
Outdated
Show resolved
Hide resolved
<dependency> | ||
<groupId>software.amazon.awssdk</groupId> | ||
<artifactId>sqs</artifactId> | ||
<version>2.25.53-SNAPSHOT</version> |
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.
This needs to be ${awsjavasdk.version}
It seems odd that we are using real service clients in codegen-generated-classes-test, is there any reason we can't use EndpointDiscoveryTestAsyncClient
...st/java/software/amazon/awssdk/core/endpointdiscovery/EndpointDiscoveryRefreshCacheTest.java
Outdated
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
Make endpoint discovery calls fully asynchronous.
Motivation and Context
Conforms to the expectation that asynchronous requests made by non-blocking clients do not block the thread.
Modifications
Created a new internal API to be invoked by asynchronous clients. This new API returns a completableFuture as opposed to waiting on request object completion
Testing
E2E test validation
Screenshots (if appropriate)
Types of changes