Skip to content

Commit

Permalink
Merge TM feature branch to mainline (#3619)
Browse files Browse the repository at this point in the history
* Replacing S3TransferManager interfaces that allowed builder methods of S3ClientConfiguration with builder methods of S3AsyncClient (#3247)

* Added customization in codegen to generate additional builder methods (#3252)

* S3Object based DownloadFilter and removing DownloadFileContext as destination based filter is removed (#3258)

* Moved tm POJO classes to model pckage and tm config classes to config package. Added integration tests for s3 select using S3CrtAsyncClient (#3289)

* Fix broken integ test (#3301)

* S3 Transfer manager renamings based on feedback: (#3297)

1. Rename destinationDirectory to destination.
2. Move DownloadDirectoryRequest.prefix and delimiter to just rely on modifying the list requests.
3. Remove upload directory recursive option in favor of using maxDepth(1).
4. Rename UploadDirectoryRequest's prefix and delimiter to s3Prefix and s3Delimiter.
5. Rename ResumableFileDownload's to* and writeTo* methods to serializeTo*. Remove charsets from write/read methods, and just use UTF-8.
6. Do not base64 encode when writing ResumableFileDownload to disk.

* Allow pausing a resumed download even when the download hasn't already started. (#3300)

* Add POJO classes for upload pause/resume (#3337)

* Refactoring of Transfer manager APIs (#3374)

* Refactoring of Transfer manager APIs

* Merging the integ test failure Pr 2119 from stagging branch

* Add flexible checksum support and update perf tests (#3376)

* Fix flexiblechecksum implementation (#3391)

* [TM upload pause/resume Part 2] Implement pause and resume for uploadFile (#3357)

* Implement pause and resume for uploadFile

* Update Javadocs

* address feedback

* Implement automatic multipart copy functionality in S3 CRT async client (#3403)

* Implement automatic multipart copy functionality in S3 CRT async client

* Add more tests

* fix cancellation logic

* Refactor CopyRequestProvider, fix request conversion and add more tests

* Fix checkstyle

* Transfer Manager tests refactoring (#3420)

* Remove use of Junit4, clean up and consolidate tests in tm module

* Ignoring the test if unicode can't be used as directory name

* Add serialization and deserialization support for ResumableFileUpload (#3432)

* Support serialization and deserialization of ResumableFileUpload

* Address feedback

* Empty json should be unmarshalled to empty map

* Errors should not be wrapped - S3 Transfer Manager (#3433)

* Errors should not be wrapped

* update handleException()

* Changelog entry

* Resolve comments
Update changelog description, refactor handleException(), add test

* Add failed message to SdkException

* Refactor handleException() and format changelog (#3461)

* Fixed an issue where SSEC params were not correctly passed in copy operation (#3464)

* Replace inline snippets with external compilable snippets (#3465)

* Replace inline snippets with external compilable snippets

* Fix build and address feedback

* Fix build

* Only enable CRT checksum for getObject and putObject (#3477)

* Only use CRT flexible checksum for getObject and putObject

* Fix build

* Fix integ tests set up and tear down steps (#3485)

* Enable backpressure in TM (#3533)

* integrate with crt s3 flow control

* Update benchmark code

* Add backpressure config

* Change window size

* Update initial window size

* Change intial window size

* Use heap max memory for initial window size

* Give some buffer

* change window size

* Make read buffer size configurable

* Log result to a file

* Various updates

* Various updates

* Add CRT benchmark

* Various updates

* Fix checkstyle errors and tests

* Fix flaky test

* Fix checkstyle errors

* Add validation

* Add tests

* For copy operation, always forward multipart copy exception from one … (#3549)

* For copy operation, always forward multipart copy exception from one request to other multipart copy requests

* Minor refactoring in CopyObjectHelper (#3552)

* Add benchmarks for copy, uploadDirectory and downloadDirectory (#3551)

* Add benchmarks for copy, uploadDirectory and downloadDirectory

* Update sample code and fix snippet path (#3567)

* Update sample code and fix snippet path

* Fix link

* Integrate with CRT checksum fix (#3566)

* Integrate with CRT checksum fix

* Rename sourceDirectory to source and add S3AsycncClient#crtCreate (#3572)

* Rname sourceDirectory to source and add S3AsycncClient#crtCreate

* Use ByteBufferStoringSubscriber (#3581)

* Use ByteBufferStoringSubscriber

* Add a comment

* Create constant for bytes bufferred

* Increase chunk size for file upload (#3583)

* Rename S3TransferManager.build().maxDepth to uploadDirectoryMaxDepth, rename S3TransferManager.builder().s3AsyncClient to .s3Client (#3584)

* Fixed an issue where sdkRepsonse is not present in the ProgressSnapshot for upload and copy (#3585)

* Throw UnsupportedOperationException if a user tries to pause a upload… (#3586)

* Throw UnsupportedOperationException if a user tries to pause a upload with non CRT-based S3 client

* Use SimplePublisher (#3594)

* Update documentation for Transfer Manager (#3592)

* Update javadoc

* Integrate with latest CRT pause/resume fix (#3588)

* Integrate with latest CRT pause/resume fix
* Bump CRT version

* Fixed an issue that could result in uncompletable future when headObject request threw exception in copy (#3609)

* Make crt dependency optional in transfer manager module (#3613)

* Make aws-crt an optional dependency in s3-transfer-manager module.

* Update README

* Fix category for changelog entries

Co-authored-by: John Viegas <70235430+joviegas@users.noreply.github.com>
Co-authored-by: Matthew Miller <millem@amazon.com>
Co-authored-by: David Ho <70000000+davidh44@users.noreply.github.com>
  • Loading branch information
4 people committed Dec 14, 2022
1 parent 98c4188 commit 63ade31
Show file tree
Hide file tree
Showing 217 changed files with 9,803 additions and 5,661 deletions.
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Require setting the bytes transferred on transfer progress snapshots. This prevents programming bugs where the caller forgets to set the value and it gets defaulted to 0."
}
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Allow pausing a resumed download, even if the resumed download hasn't started."
}
6 changes: 6 additions & 0 deletions .changes/next-release/bugfix-S3TransferManager-f1c2208.json
@@ -0,0 +1,6 @@
{
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"type": "bugfix",
"description": "Fixed issues in S3 Transfer Manager resumeDownloadFile API where errors were being wrapped by SdkClientException"
}
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Flattened and removed OverrideConfigurations such that these can be configured directly to S3TransferManagerBuilder, upload and transfer Requests. Also refactored certain attributes and API names to represent better meaningful names."
}
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Rename `UploadDirectoryRequest.prefix` and `delimiter` to `s3Prefix` and `s3Delimiter` to make it clear these are S3 parameters, not file-system parameters."
}
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Rename `DownloadDirectoryRequest.destinationDirectory` to `destination`."
}
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Rename `ResumableFileDownload`'s `to` and `writeTo` methods to `serializeTo` to make it clear that these aren't affecting the download."
}
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Do not base 64 encode when writing `ResumableFileDownload` to disk."
}
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Moved POJO classes to `software.amazon.awssdk.transfer.s3.model` and moved configuration classes to `software.amazon.awssdk.transfer.s3.config`"
}
@@ -0,0 +1,6 @@
{
"type": "removal",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Backward incompatible changes after removing s3ClientConfiguration() from builder API of S3TransferManager Interface.\n- Added crtBuilder in S3AsyncClient Interface.\n- Backward incompatible changes after changing args of test() API in DownloadFilter Interface from DownloadFileContext to S3Object."
}
@@ -0,0 +1,6 @@
{
"type": "removal",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Remove `DownloadDirectoryRequest.prefix` and `delimiter`. The same functionality is already available via the `listObjectsV2RequestTransformer`."
}
@@ -0,0 +1,6 @@
{
"type": "removal",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Remove UploadDirectoryRequest's override configuration's `recursive` option. The same functionality can be achieved with `UploadDirectoryRequest.builder().maxDepth(1)` or S3TransferManager.builder().maxUploadDirectoryDepth(1)."
}
@@ -0,0 +1,6 @@
{
"type": "removal",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Removed charset options from `ResumableFileDownload`'s string options, because there's no reason to choose something other than UTF-8."
}
6 changes: 6 additions & 0 deletions .changes/next-release/removal-S3TransferManager-2c2c795.json
@@ -0,0 +1,6 @@
{
"type": "removal",
"category": "Amazon S3 Transfer Manager",
"contributor": "",
"description": "Make `aws-crt` an optional dependency in `s3-transfer-manager` module. Customers need to explicitly add `aws-crt` dependency if they want to use CRT-based Transfer Manager"
}
Expand Up @@ -252,4 +252,18 @@
</Or>
<Bug pattern="SDK_BAD_METHOD_CALL"/>
</Match>

<!-- False positive on JDK 11+ -->
<Match>
<Class name="software.amazon.awssdk.transfer.s3.model.ResumableFileDownload"/>
<Method name="fromFile"/>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
</Match>

<!-- False positive on JDK 11+ -->
<Match>
<Class name="software.amazon.awssdk.transfer.s3.model.ResumableFileUpload"/>
<Method name="fromFile"/>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
</Match>
</FindBugsFilter>
@@ -0,0 +1,111 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package software.amazon.awssdk.codegen.model.config.customization;

import java.util.Locale;
import software.amazon.awssdk.core.ClientType;

/**
* Config required to generate the additional static methods in Client interface.
*/
public class AdditionalBuilderMethod {

/**
* Name of the additional static method.
*/
private String methodName;

/**
* Fqcn of the return type
*/
private String returnType;

/**
* Fqcn of the class that will delegate the static method call
*/
private String instanceType;

/**
* JavaDoc for the method
*/
private String javaDoc;

/**
* Method body
*/
private String statement;

/**
* The clientType for which the builder needs to be added.
*/
private ClientType clientType;

public String getReturnType() {
return returnType;
}

public void setReturnType(String returnType) {
this.returnType = returnType;
}

public String getJavaDoc() {
return javaDoc;
}

public void setJavaDoc(String javaDoc) {
this.javaDoc = javaDoc;
}

public String getMethodName() {
return methodName;
}

public void setMethodName(String methodName) {
this.methodName = methodName;
}

public String getInstanceType() {
return instanceType;
}

public void setInstanceType(String instanceType) {
this.instanceType = instanceType;
}

public String getClientType() {
return clientType != null ? clientType.toString() : null;
}

public void setClientType(String clientType) {
this.clientType = clientType != null ? ClientType.valueOf(clientType.toUpperCase(Locale.US)) : null;
}

public ClientType getClientTypeEnum() {
return clientType;
}

public void setClientTypeEnum(ClientType clientType) {
this.clientType = clientType;
}

public String getStatement() {
return statement;
}

public void setStatement(String statement) {
this.statement = statement;
}
}
Expand Up @@ -160,6 +160,11 @@ public class CustomizationConfig {
*/
private UtilitiesMethod utilitiesMethod;

/**
* Config to generate a additional Builder methods in the client interface.
*/
private List<AdditionalBuilderMethod> additionalBuilderMethods;

/**
* Force generation of deprecated client builder method 'enableEndpointDiscovery'. Only services that already had
* this method when it was deprecated require this flag to be set.
Expand Down Expand Up @@ -444,6 +449,15 @@ public void setUtilitiesMethod(UtilitiesMethod utilitiesMethod) {
this.utilitiesMethod = utilitiesMethod;
}


public List<AdditionalBuilderMethod> getAdditionalBuilderMethods() {
return additionalBuilderMethods;
}

public void setAdditionalBuilderMethods(List<AdditionalBuilderMethod> additionalBuilderMethods) {
this.additionalBuilderMethods = additionalBuilderMethods;
}

public boolean isEnableEndpointDiscoveryMethodRequired() {
return enableEndpointDiscoveryMethodRequired;
}
Expand Down
Expand Up @@ -42,6 +42,7 @@
import software.amazon.awssdk.codegen.docs.DocConfiguration;
import software.amazon.awssdk.codegen.docs.SimpleMethodOverload;
import software.amazon.awssdk.codegen.docs.WaiterDocs;
import software.amazon.awssdk.codegen.model.config.customization.AdditionalBuilderMethod;
import software.amazon.awssdk.codegen.model.config.customization.UtilitiesMethod;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.model.intermediate.OperationModel;
Expand All @@ -56,6 +57,7 @@
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.regions.ServiceMetadataProvider;
import software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain;
import software.amazon.awssdk.utils.Validate;

public class AsyncClientInterface implements ClassSpec {

Expand Down Expand Up @@ -107,6 +109,13 @@ public TypeSpec poetSpec() {
result.addMethod(utilitiesMethod());
}

List<AdditionalBuilderMethod> additionaBuilders = model.getCustomizationConfig().getAdditionalBuilderMethods();
if (additionaBuilders != null && !additionaBuilders.isEmpty()) {
additionaBuilders.stream()
.filter(builder -> software.amazon.awssdk.core.ClientType.ASYNC.equals(builder.getClientTypeEnum()))
.forEach(builders -> result.addMethod(additionalBuilders(builders)));
}

if (model.hasWaiters()) {
result.addMethod(waiterMethod());
}
Expand Down Expand Up @@ -462,6 +471,23 @@ protected MethodSpec utilitiesMethod() {
return utilitiesOperationBody(builder).build();
}

private MethodSpec additionalBuilders(AdditionalBuilderMethod additionalMethod) {

String methodName = Validate.paramNotNull(additionalMethod.getMethodName(), "methodName");
ClassName returnType = PoetUtils.classNameFromFqcn(
Validate.paramNotNull(additionalMethod.getReturnType(), "returnType"));
ClassName instanceType = PoetUtils.classNameFromFqcn(
Validate.paramNotNull(additionalMethod.getInstanceType(), "instanceType"));

MethodSpec.Builder builder = MethodSpec.methodBuilder(methodName)
.returns(returnType)
.addModifiers(Modifier.STATIC, Modifier.PUBLIC)
.addJavadoc(additionalMethod.getJavaDoc())
.addStatement("return $T.$L", instanceType, additionalMethod.getStatement());

return builder.build();
}

protected MethodSpec.Builder utilitiesOperationBody(MethodSpec.Builder builder) {
return builder.addModifiers(Modifier.DEFAULT).addStatement("throw new $T()", UnsupportedOperationException.class);
}
Expand Down
Expand Up @@ -56,7 +56,7 @@ public TypeSpec poetSpec() {
.addAnnotation(SdkInternalApi.class)
.addModifiers(Modifier.ABSTRACT, Modifier.PUBLIC)
.addField(FieldSpec.builder(interfaceClass, "delegate")
.addModifiers(Modifier.PRIVATE, Modifier.FINAL)
.addModifiers(Modifier.PROTECTED, Modifier.FINAL)
.build())
.addMethods(operations())
.addMethod(closeMethod());
Expand Down
Expand Up @@ -22,6 +22,40 @@
"returnType": "software.amazon.awssdk.services.json.JsonUtilities",
"createMethodParams": ["param1", "param2", "param3"]
},
"additionalBuilderMethods": [
{
"methodName": "builderOne",
"clientType": "ASYNC",
"instanceType": "software.amazon.awssdk.services.builder.DefaultBuilder",
"returnType": "software.amazon.awssdk.services.builder.CustomBuilder",
"statement": "builder().build()",
"javaDoc": "Create a default builder"
},
{
"methodName": "builderTwo",
"clientType": "ASYNC",
"instanceType": "software.amazon.awssdk.services.builder.DefaultBuilderTwo",
"returnType": "software.amazon.awssdk.services.builder.Builder",
"statement": "builder2().build()",
"javaDoc": "Create a default builder two"
},

{
"methodName": "builderThree",
"clientType": "SYNC",
"instanceType": "software.amazon.awssdk.services.builder.DefaultBuilder",
"returnType": "software.amazon.awssdk.services.builder.CustomBuilder",
"statement": "builder().build()",
"javaDoc": "Create a default builder"
},
{
"methodName": "builderFour",
"instanceType": "software.amazon.awssdk.services.builder.DefaultBuilder",
"returnType": "software.amazon.awssdk.services.builder.CustomBuilder",
"statement": "builder().build()",
"javaDoc": "Create a default builder"
}
],
"useLegacyEventGenerationScheme": {
"EventStream": ["EventOne", "event-two", "eventThree"]
},
Expand Down
Expand Up @@ -46,7 +46,7 @@
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
public abstract class DelegatingJsonAsyncClient implements JsonAsyncClient {
private final JsonAsyncClient delegate;
protected final JsonAsyncClient delegate;

public DelegatingJsonAsyncClient(JsonAsyncClient delegate) {
this.delegate = delegate;
Expand Down

0 comments on commit 63ade31

Please sign in to comment.