-
Notifications
You must be signed in to change notification settings - Fork 910
Remove the use of S3NativeClient and integrate with S3Client #2976
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
Conversation
0e48aac
to
1e593ae
Compare
http-client-spi/src/main/java/software/amazon/awssdk/http/SdkHttpExecutionAttributes.java
Outdated
Show resolved
Hide resolved
http-client-spi/src/main/java/software/amazon/awssdk/http/async/AsyncExecuteRequest.java
Outdated
Show resolved
Hide resolved
http-client-spi/src/main/java/software/amazon/awssdk/http/async/AsyncExecuteRequest.java
Outdated
Show resolved
Hide resolved
...3-transfer-manager/src/it/java/software/amazon/awssdk/transfer/s3/S3IntegrationTestBase.java
Show resolved
Hide resolved
...er-manager/src/main/java/software/amazon/awssdk/transfer/s3/S3CrtResponseHandlerAdapter.java
Outdated
Show resolved
Hide resolved
...-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/S3CrtAsyncHttpClient.java
Show resolved
Hide resolved
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.
.metricCollector(httpMetricCollector) | ||
.build(); | ||
.metricCollector(httpMetricCollector); | ||
if (context.executionAttributes().getAttribute(SDK_HTTP_EXECUTION_ATTRIBUTES) != null) { |
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 add a variant of getAttribute()
that returns an Optional
, so we don't have to do multiple lookups? It's a hyper-nit in terms of performance, but it would also help readability in places like this.
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.
Yeah, it'd be nice to have another method returning optional but since overload is not possible, I'd be hesitant to introduce another method with a different name unless we have strong reasons.
executeRequestBuilder.httpExecutionAttributes( | ||
context.executionAttributes() | ||
.getAttribute(SDK_HTTP_EXECUTION_ATTRIBUTES)); |
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.
What if we just copied all executionAttributes
to the request, rather than selectively choosing which ones to copy? Are we worried that would leak abstractions that are not relevant to the request?
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.
Yeah, most of the execution attributes are used in the SDK core and not relevant to the HTTP request.
http-client-spi/src/main/java/software/amazon/awssdk/http/SdkHttpExecutionAttributes.java
Outdated
Show resolved
Hide resolved
http-client-spi/src/main/java/software/amazon/awssdk/http/SdkHttpExecutionAttributes.java
Outdated
Show resolved
Hide resolved
|
||
private AsyncExecuteRequest(BuilderImpl builder) { | ||
this.request = builder.request; | ||
this.requestContentPublisher = builder.requestContentPublisher; | ||
this.responseHandler = builder.responseHandler; | ||
this.metricCollector = builder.metricCollector; | ||
this.isFullDuplex = builder.isFullDuplex; | ||
this.sdkHttpExecutionAttributes = builder.executionAttributesBuilder.build(); |
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 this be referencing a builder or an already-built object?
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.
What do you mean? Is there any benefit of referencing an already-built object?
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.
It seems unusual to me that we're calling builder.executionAttributesBuilder.build()
rather than just builder.executionAttributes
.
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 see, executionAttributes is immutable, so we have to keep a executionAttributesBuilder
in the Builder inner class to allow users to provide a single attribute. We could add another executionAttributes
field which will be built in the AsyncExecuteRequest build()
method, but I feel it's a bit overkill.
*/ | ||
@SdkInternalApi | ||
public final class RequestDataSupplierAdapter implements RequestDataSupplier { | ||
public final class RequestDataSupplierAdapter implements HttpRequestBodyStream { |
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: Also rename RequestDataSupplierAdapter
?
|
||
@Override | ||
public String clientName() { | ||
return "s3crt"; |
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.
Does this follow our normal naming convention? I see other names like NettyNio
, AwsCommonRuntime
, Apache
, etc.
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 is used in the user agent header. Per the new standard, we should make it as short as possible and lower case
// Add the rest of the Headers | ||
sdkRequest.headers().forEach((key, value) -> value.stream().map(val -> new HttpHeader(key, val)) | ||
.forEach(crtHeaderList::add)); |
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.
Is this not going to result in adding duplicates for host/content-length?
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.
No, host and content-length will only be added if they are not present in the sdkRequest headers
} | ||
} | ||
|
||
private static boolean isErrorResponse(int responseStatus) { |
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 this be checking crtCode
or responseStatus
? I would assume crtCode
would be non-zero based, while responseStatus
would be HTTP status code based?
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.
isErrorResponse
is more of if there is an error response from the service. Apparently, responseStatus == 0
means the HTTP request itself fails.
|
||
private void handleError(int crtCode, int responseStatus, byte[] errorPayload) { | ||
if (isErrorResponse(responseStatus) && errorPayload != null) { | ||
publisher.deliverData(ByteBuffer.wrap(errorPayload)); |
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.
Is it safe to assume the byte[]
won't be reused?
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.
Yeah, I don't think it will be reused by CRT
SonarCloud Quality Gate failed. |
…240fc58e8 Pull request: release <- staging/47dc0a16-ab58-44a9-9b5e-36a240fc58e8
Context
S3NativeClient: an S3 SDK client provided in the aws-crt-java. It handles the full request lifecycle: marshalling, signing, sending HTTP requests, retrying, unmarshalling.
S3Client: HTTP abstraction specific to S3 provided in aws-crt-java. It handles signing, sending HTTP requests and retrying.
Description
This PR removes the use of
S3NativeClient
and integrates withS3Client
in the transfer manager. The integration is implemented by wrappingS3Client
withSdkAsyncHttpClient
and passing the HTTP client to the java S3AsyncClient with certain java features disabled.This should fix #2864
Below are the public API changes:
AsyncExecuteRequest
now takes additional SDK HTTP execution attributes. This is required to pass credentials, region and other s3 settings to the S3 HTTP client.Testing
Added unit tests.
Integ tests and stability tests passed
Screenshots (if appropriate)
Types of changes
Checklist
mvn install
succeedsLicense