-
Notifications
You must be signed in to change notification settings - Fork 55
feat: project setup and upload file #1712
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
base: s3-tm-main
Are you sure you want to change the base?
Conversation
|
A new generated diff is ready to view.
|
|
A new generated diff is ready to view.
|
|
A new generated diff is ready to view.
|
|
A new generated diff is ready to view.
|
|
A new generated diff is ready to view.
|
lauzadis
left a comment
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.
Nice start
...mmon/src/aws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetricsUtils.kt
Show resolved
Hide resolved
hll/s3-transfer-manager/jvm/test/aws/sdk/kotlin/hll/s3transfermanager/UploadFileTest.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/utils/UploadFile.kt
Outdated
Show resolved
Hide resolved
...ransfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/BusinessMetricInterceptor.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/S3TransferManager.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/S3TransferManager.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/S3TransferManager.kt
Outdated
Show resolved
Hide resolved
...-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/model/UploadFileRequest.kt
Outdated
Show resolved
Hide resolved
...-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/model/UploadFileRequest.kt
Outdated
Show resolved
Hide resolved
...-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/model/UploadFileRequest.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/utils/UploadFile.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/utils/UploadFile.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/S3TransferManager.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/S3TransferManager.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/S3TransferManager.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/TransferInterceptor.kt
Outdated
Show resolved
Hide resolved
|
A new generated diff is ready to view.
|
|
A new generated diff is ready to view. |
|
A new generated diff is ready to view. |
|
A new generated diff is ready to view. |
|
A new generated diff is ready to view. |
...n/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/OperationRenderer.kt
Outdated
Show resolved
Hide resolved
...odegen/src/main/kotlin/aws/sdk/kotlin/hll/s3transfermanager/codegen/mappings/MappingTypes.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/S3TransferManager.kt
Show resolved
Hide resolved
...-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/operations/uploadfile/UploadFile.kt
Outdated
Show resolved
Hide resolved
...ger/common/src/aws/sdk/kotlin/hll/s3transfermanager/operations/uploadfile/HelperFunctions.kt
Outdated
Show resolved
Hide resolved
...mon/src/aws/sdk/kotlin/hll/s3transfermanager/operations/uploadfile/hooks/InitiateTransfer.kt
Outdated
Show resolved
Hide resolved
...common/test/aws/sdk/kotlin/hll/s3transfermanager/operations/uploadobject/UploadObjectTest.kt
Show resolved
Hide resolved
|
A new generated diff is ready to view. |
hll/build.gradle.kts
Outdated
|
|
||
| "s3-transfer-manager-codegen", // TODO: Disable publishing ? |
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.
Comment: 👍 Yes, this is in the right place. We don't want to publish this since we have no use case for it right now. We can scratch the TODO.
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 doesn't disable publication right? Just API validation and docgen
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 configured in repo tools right?
| val mpuUploadId = initiateTransfer( | ||
| multipartUpload, | ||
| transferContext, | ||
| contentLength, | ||
| uploadFileRequest, | ||
| interceptors, | ||
| client, | ||
| ) | ||
|
|
||
| val uploadedParts = transferBytes( | ||
| multipartUpload, | ||
| contentLength, | ||
| partSizeBytes, | ||
| logger, | ||
| uploadFileRequest, | ||
| transferContext, | ||
| mpuUploadId, | ||
| interceptors, | ||
| client, | ||
| maxInMemoryParts, | ||
| maxConcurrentPartUploads, | ||
| ) | ||
|
|
||
| completeTransfer( | ||
| multipartUpload, | ||
| transferContext, | ||
| uploadFileRequest, | ||
| mpuUploadId, | ||
| uploadedParts, | ||
| interceptors, | ||
| client, | ||
| ) |
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.
Style: The volume of arguments passed into these functions is too great. Can any of these be grouped into objects, derived from other parameters, etc.? This level of data coupling is an indicator that we might be better served modelling a base operation type which can be implemented for each operation type (e.g., UploadFile) or for each subtype (e.g., UploadFileSingle and UploadFileMultipart), which would reduce the amount of if (multipartUpload) calls.
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 left a TODO for this, once we write other operations it'll be easier to create a common abstraction.
...c/main/kotlin/aws/sdk/kotlin/hll/s3transfermanager/codegen/mappings/uploadfile/Converters.kt
Outdated
Show resolved
Hide resolved
...common/src/aws/sdk/kotlin/hll/s3transfermanager/operations/uploadfile/hooks/TransferBytes.kt
Outdated
Show resolved
Hide resolved
| ) = produce( | ||
| capacity = maxInMemoryParts, | ||
| ) { |
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.
Correctness: Isn't maxInMemoryParts supposed to limit the parts for the entire S3TM? This looks like it applies to individual objects but we'll be parallelizing multi-object transfers.
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 decided to use a Channel for each object but while keeping track of total parts in memory using a Semaphore.
...common/src/aws/sdk/kotlin/hll/s3transfermanager/operations/uploadfile/hooks/TransferBytes.kt
Show resolved
Hide resolved
hll/build.gradle.kts
Outdated
|
|
||
| "s3-transfer-manager-codegen", // TODO: Disable publishing ? |
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 doesn't disable publication right? Just API validation and docgen
| internal val uploadFileConversions = listOf( | ||
| ConversionMapping( | ||
| source = TypeRef( | ||
| "aws.sdk.kotlin.services.s3.model", | ||
| "PutObjectResponse", | ||
| ), | ||
| destination = TypeRef( | ||
| "aws.sdk.kotlin.hll.s3transfermanager.model", | ||
| "UploadFileResponse", | ||
| ), | ||
| setOf( | ||
| "bucketKeyEnabled", | ||
| "checksumCrc32", | ||
| "checksumCrc32C", | ||
| "checksumCrc64Nvme", | ||
| "checksumSha1", | ||
| "checksumSha256", | ||
| "checksumType", | ||
| "eTag", | ||
| "expiration", |
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 don't think a data string will make this any more readable / maintainable? The internal spec already has this modeled as a JSON list, we can make changes (which I believe are unlikely) by inspecting the diff of that file
| /** | ||
| * Preferred part size for multipart uploads. | ||
| * If using this size would require more than 10,000 parts (the S3 limit), | ||
| * the smallest possible part size that results in 10,000 parts is used instead. | ||
| * | ||
| * Default to 8,000,000 bytes. | ||
| */ | ||
| public val partSizeBytes: Long = builder.partSizeBytes |
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 my fault since I left a comment asking to change it to just partSize to simplify the name. We are logging a warning when deviating from the configured part size. It's not a strong opinion so I will let @0marperez make the decision
|
A new generated diff is ready to view. |
ianbotsf
left a comment
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.
Looking pretty good, down to the final sticking point!
| write("@PublishedApi") | ||
| write( | ||
| "internal fun build(): #1L = #1L(this)", | ||
| className, | ||
| ) |
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.
Question: Why is @PublishedApi necessary here? Is this getting inlined somewhere?
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's getting inlined by the public invoke function. It used to be public but you asked to make it internal. I used @PublishedApi because it's what we use often in the rest of the codebase.
...tlin/aws/sdk/kotlin/hll/s3transfermanager/codegen/utils/S3TransferManagerCodegenException.kt
Outdated
Show resolved
Hide resolved
| executePhase( | ||
| TransferPhase.BytesTransferred, | ||
| localContext, | ||
| interceptors, | ||
| ) { | ||
| localContext.s3Response = client.withTmBusinessMetric { | ||
| it.uploadPart(localContext.s3Request as UploadPartRequest) | ||
| } | ||
|
|
||
| // -1 part in memory | ||
| semaphore.release() | ||
|
|
||
| localContext.transferredBytes = localContext.transferredBytes!! + partSize | ||
| } |
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.
Question: executePhase only invokes the given block if no exception is thrown first, right? When an exception is thrown, what should happen to the part in memory and the semaphore? Presently it looks like they stay stuck and won't be 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.
I added a try/catch block around the consumer to make sure the parts don't stay in memory and we update the semaphore.
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'm guessing your question is for when users are try/catching their S3 TM requests and then continue making S3 TM calls?
| /** | ||
| * The context around an [aws.sdk.kotlin.hll.s3transfermanager.S3TransferManager] transfer. | ||
| * Used to track transfer progress or to modify in progress transfers. | ||
| */ | ||
| public data class TransferContext( | ||
| override val s3Request: Any? = null, | ||
| override val s3Response: Any? = null, | ||
| override val tmRequest: Any? = null, | ||
| override val tmResponse: Any? = null, | ||
| override val transferableBytes: Long? = null, | ||
| override val transferredBytes: Long? = null, | ||
| override val transferableObjects: Long? = null, | ||
| override val transferredObjects: Long? = null, | ||
| ) : TransferInterceptorContext | ||
|
|
||
| /** | ||
| * The context around an [aws.sdk.kotlin.hll.s3transfermanager.S3TransferManager] transfer. | ||
| * Used to track transfer progress or to modify in progress transfers. | ||
| */ | ||
| public data class MutableTransferContext( | ||
| override var s3Request: Any? = null, | ||
| override var s3Response: Any? = null, | ||
| override var tmRequest: Any? = null, | ||
| override var tmResponse: Any? = null, | ||
| override var transferableBytes: Long? = null, | ||
| override var transferredBytes: Long? = null, | ||
| override var transferableObjects: Long? = null, | ||
| override var transferredObjects: Long? = null, | ||
| ) : TransferInterceptorContext { | ||
| internal fun immutableCopy() = | ||
| TransferContext( | ||
| s3Request, | ||
| s3Response, | ||
| tmRequest, | ||
| tmResponse, | ||
| transferableBytes, | ||
| transferredBytes, | ||
| transferableObjects, | ||
| transferredObjects, | ||
| ) | ||
| } |
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.
Correctness: We must not expose data class types in our public API. Can the implementations be internal instead?
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.
Changed these to classes. I think they need to be public or either internal with @PublishedApi since they're exposed to the user in TransferInterceptor.
...r/common/src/aws/sdk/kotlin/hll/s3transfermanager/operations/uploadobject/HelperFunctions.kt
Outdated
Show resolved
Hide resolved
...-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/utils/S3TransferManagerException.kt
Outdated
Show resolved
Hide resolved
hll/s3-transfer-manager/common/src/aws/sdk/kotlin/hll/s3transfermanager/S3TransferManager.kt
Show resolved
Hide resolved
|
A new generated diff is ready to view. |
Issue #
N/A
Description of changes
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.