|
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,33 @@ 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 | + .disableMultiRegionAccessPoints(builder.disableMultiRegionAccessPoints) |
| 101 | + .forcePathStyle(builder.forcePathStyle) |
| 102 | + .useArnRegion(builder.useArnRegion) |
88 | 103 | .httpClientBuilder(initializeS3CrtAsyncHttpClient(builder))
|
89 | 104 | .build();
|
90 | 105 | }
|
@@ -123,6 +138,12 @@ public static final class DefaultS3CrtClientBuilder implements S3CrtAsyncClientB
|
123 | 138 | private URI endpointOverride;
|
124 | 139 | private Boolean checksumValidationEnabled;
|
125 | 140 | private S3CrtHttpConfiguration httpConfiguration;
|
| 141 | + private Boolean accelerate; |
| 142 | + private Boolean disableMultiRegionAccessPoints; |
| 143 | + private Boolean forcePathStyle; |
| 144 | + private Boolean useArnRegion; |
| 145 | + |
| 146 | + private List<ExecutionInterceptor> executionInterceptors; |
126 | 147 |
|
127 | 148 | public AwsCredentialsProvider credentialsProvider() {
|
128 | 149 | return credentialsProvider;
|
@@ -206,6 +227,39 @@ public S3CrtAsyncClientBuilder httpConfiguration(S3CrtHttpConfiguration configur
|
206 | 227 | return this;
|
207 | 228 | }
|
208 | 229 |
|
| 230 | + @Override |
| 231 | + public S3CrtAsyncClientBuilder accelerate(Boolean accelerate) { |
| 232 | + this.accelerate = accelerate; |
| 233 | + return this; |
| 234 | + } |
| 235 | + |
| 236 | + @Override |
| 237 | + public S3CrtAsyncClientBuilder disableMultiRegionAccessPoints(Boolean disableMultiRegionAccessPoints) { |
| 238 | + this.disableMultiRegionAccessPoints = disableMultiRegionAccessPoints; |
| 239 | + return this; |
| 240 | + } |
| 241 | + |
| 242 | + @Override |
| 243 | + public S3CrtAsyncClientBuilder forcePathStyle(Boolean forcePathStyle) { |
| 244 | + this.forcePathStyle = forcePathStyle; |
| 245 | + return this; |
| 246 | + } |
| 247 | + |
| 248 | + @Override |
| 249 | + public S3CrtAsyncClientBuilder useArnRegion(Boolean useArnRegion) { |
| 250 | + this.useArnRegion = useArnRegion; |
| 251 | + return this; |
| 252 | + } |
| 253 | + |
| 254 | + @SdkTestInternalApi |
| 255 | + S3CrtAsyncClientBuilder addExecutionInterceptor(ExecutionInterceptor executionInterceptor) { |
| 256 | + if (executionInterceptors == null) { |
| 257 | + this.executionInterceptors = new ArrayList<>(); |
| 258 | + } |
| 259 | + executionInterceptors.add(executionInterceptor); |
| 260 | + return this; |
| 261 | + } |
| 262 | + |
209 | 263 | @Override
|
210 | 264 | public S3CrtAsyncClient build() {
|
211 | 265 | return new DefaultS3CrtAsyncClient(this);
|
|
0 commit comments