|
21 | 21 | import static software.amazon.awssdk.services.s3.internal.crt.S3NativeClientConfiguration.DEFAULT_PART_SIZE_IN_BYTES;
|
22 | 22 |
|
23 | 23 | import java.net.URI;
|
| 24 | +import java.util.ArrayList; |
| 25 | +import java.util.List; |
24 | 26 | import java.util.concurrent.CompletableFuture;
|
25 | 27 | import software.amazon.awssdk.annotations.SdkInternalApi;
|
| 28 | +import software.amazon.awssdk.annotations.SdkTestInternalApi; |
26 | 29 | import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
|
27 | 30 | import software.amazon.awssdk.awscore.AwsRequest;
|
28 | 31 | import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
|
29 | 32 | import software.amazon.awssdk.core.SdkRequest;
|
30 | 33 | import software.amazon.awssdk.core.checksums.ChecksumValidation;
|
| 34 | +import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration; |
31 | 35 | import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption;
|
32 | 36 | import software.amazon.awssdk.core.interceptor.Context;
|
33 | 37 | import software.amazon.awssdk.core.interceptor.ExecutionAttributes;
|
@@ -69,22 +73,31 @@ public CompletableFuture<CopyObjectResponse> copyObject(CopyObjectRequest copyOb
|
69 | 73 | }
|
70 | 74 |
|
71 | 75 | private static S3AsyncClient initializeS3AsyncClient(DefaultS3CrtClientBuilder builder) {
|
| 76 | + ClientOverrideConfiguration.Builder overrideConfigurationBuilder = |
| 77 | + ClientOverrideConfiguration.builder() |
| 78 | + // Disable checksum, retry policy and signer because they are handled in crt |
| 79 | + .putAdvancedOption(SdkAdvancedClientOption.SIGNER, new NoOpSigner()) |
| 80 | + .putExecutionAttribute(SdkExecutionAttribute.HTTP_RESPONSE_CHECKSUM_VALIDATION, |
| 81 | + ChecksumValidation.FORCE_SKIP) |
| 82 | + .retryPolicy(RetryPolicy.none()) |
| 83 | + .addExecutionInterceptor(new ValidateRequestInterceptor()) |
| 84 | + .addExecutionInterceptor(new AttachHttpAttributesExecutionInterceptor()); |
| 85 | + |
| 86 | + if (builder.executionInterceptors != null) { |
| 87 | + builder.executionInterceptors.forEach(overrideConfigurationBuilder::addExecutionInterceptor); |
| 88 | + } |
| 89 | + |
72 | 90 | return S3AsyncClient.builder()
|
73 |
| - // Disable checksum, retry policy and signer because they are handled in crt |
| 91 | + // Disable checksum, it is handled in CRT |
74 | 92 | .serviceConfiguration(S3Configuration.builder()
|
75 | 93 | .checksumValidationEnabled(false)
|
76 | 94 | .build())
|
77 | 95 | .region(builder.region)
|
78 | 96 | .endpointOverride(builder.endpointOverride)
|
79 | 97 | .credentialsProvider(builder.credentialsProvider)
|
80 |
| - .overrideConfiguration(o -> o.putAdvancedOption(SdkAdvancedClientOption.SIGNER, |
81 |
| - new NoOpSigner()) |
82 |
| - .putExecutionAttribute( |
83 |
| - SdkExecutionAttribute.HTTP_RESPONSE_CHECKSUM_VALIDATION, |
84 |
| - ChecksumValidation.FORCE_SKIP) |
85 |
| - .retryPolicy(RetryPolicy.none()) |
86 |
| - .addExecutionInterceptor(new ValidateRequestInterceptor()) |
87 |
| - .addExecutionInterceptor(new AttachHttpAttributesExecutionInterceptor())) |
| 98 | + .overrideConfiguration(overrideConfigurationBuilder.build()) |
| 99 | + .accelerate(builder.accelerate) |
| 100 | + .forcePathStyle(builder.forcePathStyle) |
88 | 101 | .httpClientBuilder(initializeS3CrtAsyncHttpClient(builder))
|
89 | 102 | .build();
|
90 | 103 | }
|
@@ -123,6 +136,10 @@ public static final class DefaultS3CrtClientBuilder implements S3CrtAsyncClientB
|
123 | 136 | private URI endpointOverride;
|
124 | 137 | private Boolean checksumValidationEnabled;
|
125 | 138 | private S3CrtHttpConfiguration httpConfiguration;
|
| 139 | + private Boolean accelerate; |
| 140 | + private Boolean forcePathStyle; |
| 141 | + |
| 142 | + private List<ExecutionInterceptor> executionInterceptors; |
126 | 143 |
|
127 | 144 | public AwsCredentialsProvider credentialsProvider() {
|
128 | 145 | return credentialsProvider;
|
@@ -206,6 +223,27 @@ public S3CrtAsyncClientBuilder httpConfiguration(S3CrtHttpConfiguration configur
|
206 | 223 | return this;
|
207 | 224 | }
|
208 | 225 |
|
| 226 | + @Override |
| 227 | + public S3CrtAsyncClientBuilder accelerate(Boolean accelerate) { |
| 228 | + this.accelerate = accelerate; |
| 229 | + return this; |
| 230 | + } |
| 231 | + |
| 232 | + @Override |
| 233 | + public S3CrtAsyncClientBuilder forcePathStyle(Boolean forcePathStyle) { |
| 234 | + this.forcePathStyle = forcePathStyle; |
| 235 | + return this; |
| 236 | + } |
| 237 | + |
| 238 | + @SdkTestInternalApi |
| 239 | + S3CrtAsyncClientBuilder addExecutionInterceptor(ExecutionInterceptor executionInterceptor) { |
| 240 | + if (executionInterceptors == null) { |
| 241 | + this.executionInterceptors = new ArrayList<>(); |
| 242 | + } |
| 243 | + executionInterceptors.add(executionInterceptor); |
| 244 | + return this; |
| 245 | + } |
| 246 | + |
209 | 247 | @Override
|
210 | 248 | public S3CrtAsyncClient build() {
|
211 | 249 | return new DefaultS3CrtAsyncClient(this);
|
|
0 commit comments