-
Notifications
You must be signed in to change notification settings - Fork 910
Refactor S3TransferManager to support non-file-based transfers #2817
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
Refactor S3TransferManager to support non-file-based transfers #2817
Conversation
## Motivation We would like for S3TransferManager to support non-file-based uploads and downloads, such as reactive streams or in-memory byte buffers, but the current implementation is directly coupled to file/Path-based transfers. While the underlying S3AsyncClient already has support for AsyncRequestBodies and AsyncResponseTransformers, these constructs are not exposed through the current S3TransferManager interface. Additionally, the existing S3TransferManager interfaces have made some assumptions that make it difficult to introduce this support, such as UploadRequest/DownloadRequest having a Path attribute, and not having interfaces that allow us to distinguish between transfer types, e.g., single-object and multi-object (directory) transfers. Likewise, the current interface hierarchy also makes it difficult to distinguish between file-based and non-file-based. Therefore, this refactoring requires backwards-incompatible changes, which are permissible while S3TransferManager is still in PREVIEW. ## Modifications The diff here is very large, but this change set primarily introduces the following interface hierarchy: * TransferRequest * TransferObjectRequest * UploadFileRequest * DownloadFileRequest * UploadRequest * DownloadRequest<T> * TransferDirectoryRequest * UploadDirectoryRequest * Transfer * ObjectTransfer * FileUpload * FileDownload * Upload * Download<T> * DirectoryTransfer * DirectoryUpload * CompletedTransfer * CompletedObjectTransfer * CompletedFileUpload * CompletedFileDownload * CompletedUpload * CompletedDownload<T> * CompletedDirectoryTransfer * CompletedDirectoryUpload * FailedObjectTransfer * FailedFileUpload These interfaces allow us to more selectively choose which attributes will be shared between different data types. Additionally, we take this opportunity to make the naming convention and class-vs-interface distinction consistent across all the above data types. It is important that we distinguish between file-based-requests and non-file-based-requests so that the Collection<> of failed file transfers from a directory upload can be re-driven, if needed. Note that the above Download-oriented data types are all generic. This is because of how AsyncResponseTransformer is designed to be generic, being parameterized with the type of data that a given AsyncResponseTransformer produces. Therefore, a user must declare the type at the time of instantiating a DownloadRequest, and the type will be consistent throughout the transfer lifecycle, including the Download and CompletedDownload interfaces.
@Bennett-Lynch |
...fer-manager/src/main/java/software/amazon/awssdk/transfer/s3/CompletedDirectoryTransfer.java
Outdated
Show resolved
Hide resolved
...fer-manager/src/main/java/software/amazon/awssdk/transfer/s3/CompletedDirectoryTransfer.java
Outdated
Show resolved
Hide resolved
...fer-manager/src/main/java/software/amazon/awssdk/transfer/s3/CompletedDirectoryTransfer.java
Show resolved
Hide resolved
...nsfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/CompletedDirectoryUpload.java
Outdated
Show resolved
Hide resolved
.../s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/CompletedDownload.java
Show resolved
Hide resolved
...3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/CompletedFileUpload.java
Outdated
Show resolved
Hide resolved
...om/s3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/CompletedUpload.java
Outdated
Show resolved
Hide resolved
...anager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultDirectoryUpload.java
Outdated
Show resolved
Hide resolved
...ager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultS3TransferManager.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.
Can we update the sample code in the README? cc @Carey-AWS, can we update dev guide?
...3-transfer-manager/src/main/java/software/amazon/awssdk/transfer/s3/CompletedFileUpload.java
Show resolved
Hide resolved
...r-manager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultFileDownload.java
Show resolved
Hide resolved
...ager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DefaultS3TransferManager.java
Show resolved
Hide resolved
@zoewangg I updated the README. I wasn't sure if we should include examples for the arbitrary upload/download, or just file transfers (to keep it simple). Please take a look at let me know what you prefer. |
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.
Thanks for updating the README, LGTM. I think we should have sample code for common use-cases like what you added. The DDB enhanced client README is a good example, imo and we've got positive feedback on it. https://github.com/aws/aws-sdk-java-v2/tree/master/services-custom/dynamodb-enhanced
SonarCloud Quality Gate failed. |
Revision 2 (ffc3deb, 4aac24a)
Revision 1 (995ca7d)
Motivation and Context
We would like for S3TransferManager to support non-file-based uploads and downloads, such as reactive streams or in-memory byte buffers, but the current implementation is directly coupled to file/Path-based transfers. While the underlying S3AsyncClient already has support for AsyncRequestBodies and AsyncResponseTransformers, these constructs are not exposed through the current S3TransferManager interface.
Additionally, the existing S3TransferManager interfaces have made some assumptions that make it difficult to introduce this support, such as UploadRequest/DownloadRequest having a Path attribute, and not having interfaces that allow us to distinguish between transfer types, e.g., single-object and multi-object (directory) transfers. Likewise, the current interface hierarchy also makes it difficult to distinguish between file-based and non-file-based. Therefore, this refactoring requires backwards-incompatible changes, which are permissible while S3TransferManager is still in PREVIEW.
Description
The diff here is very large, but this change set primarily introduces the following interface hierarchy:
These interfaces allow us to more selectively choose which attributes will be shared between different data types. Additionally, we take this opportunity to make the naming convention and class-vs-interface distinction consistent across all the above data types.
It is important that we distinguish between file-based-requests and non-file-based-requests so that the Collection<> of failed file transfers from a directory upload can be re-driven, if needed.
Note that the above Download-oriented data types are all generic. This is because of how AsyncResponseTransformer is designed to be generic, being parameterized with the type of data that a given AsyncResponseTransformer produces. Therefore, a user must declare the type at the time of instantiating a DownloadRequest, and the type will
be consistent throughout the transfer lifecycle, including the Download and CompletedDownload interfaces.
For a quick overview of the new API, refer to the upload/download integration tests:
Arbitrary object transfers
aws-sdk-java-v2/services-custom/s3-transfer-manager/src/it/java/software/amazon/awssdk/transfer/s3/S3TransferManagerUploadIntegrationTest.java
Lines 92 to 99 in 995ca7d
aws-sdk-java-v2/services-custom/s3-transfer-manager/src/it/java/software/amazon/awssdk/transfer/s3/S3TransferManagerDownloadIntegrationTest.java
Lines 79 to 86 in 995ca7d
File-based transfers
aws-sdk-java-v2/services-custom/s3-transfer-manager/src/it/java/software/amazon/awssdk/transfer/s3/S3TransferManagerUploadIntegrationTest.java
Lines 69 to 76 in 995ca7d
aws-sdk-java-v2/services-custom/s3-transfer-manager/src/it/java/software/amazon/awssdk/transfer/s3/S3TransferManagerDownloadIntegrationTest.java
Lines 66 to 72 in 995ca7d
License