-
Notifications
You must be signed in to change notification settings - Fork 867
Add multipartupload lifecycle tracking #4061
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "services": [ | ||
| { | ||
| "serviceName": "S3", | ||
| "type": "minor", | ||
| "changeLogMessages": [ | ||
| "Added UploadInitiatedEvent, UploadCompletedEvent, and UploadFailedEvent for multipart uploads." | ||
| ] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -33,21 +33,33 @@ internal partial class MultipartUploadCommand : BaseCommand | |||||
|
|
||||||
| public override async Task ExecuteAsync(CancellationToken cancellationToken) | ||||||
| { | ||||||
| // Fire transfer initiated event FIRST, before choosing path | ||||||
| FireTransferInitiatedEvent(); | ||||||
|
|
||||||
| if ( (this._fileTransporterRequest.InputStream != null && !this._fileTransporterRequest.InputStream.CanSeek) || this._fileTransporterRequest.ContentLength == -1) | ||||||
| { | ||||||
| await UploadUnseekableStreamAsync(this._fileTransporterRequest, cancellationToken).ConfigureAwait(false); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| var initRequest = ConstructInitiateMultipartUploadRequest(); | ||||||
| var initResponse = await _s3Client.InitiateMultipartUploadAsync(initRequest, cancellationToken) | ||||||
| InitiateMultipartUploadResponse initResponse = null; | ||||||
| try | ||||||
| { | ||||||
| var initRequest = ConstructInitiateMultipartUploadRequest(); | ||||||
| initResponse = await _s3Client.InitiateMultipartUploadAsync(initRequest, cancellationToken) | ||||||
| .ConfigureAwait(continueOnCapturedContext: false); | ||||||
| Logger.DebugFormat("Initiated upload: {0}", initResponse.UploadId); | ||||||
| Logger.DebugFormat("Initiated upload: {0}", initResponse.UploadId); | ||||||
| } | ||||||
| catch (Exception) | ||||||
| { | ||||||
| FireTransferFailedEvent(); | ||||||
| throw; | ||||||
| } | ||||||
|
|
||||||
| var pendingUploadPartTasks = new List<Task<UploadPartResponse>>(); | ||||||
|
|
||||||
| SemaphoreSlim localThrottler = null; | ||||||
| CancellationTokenSource internalCts = null; | ||||||
|
|
||||||
| try | ||||||
| { | ||||||
| Logger.DebugFormat("Queue up the UploadPartRequests to be executed"); | ||||||
|
|
@@ -101,14 +113,19 @@ await localThrottler.WaitAsync(cancellationToken) | |||||
|
|
||||||
| Logger.DebugFormat("Beginning completing multipart. ({0})", initResponse.UploadId); | ||||||
| var compRequest = ConstructCompleteMultipartUploadRequest(initResponse); | ||||||
| await this._s3Client.CompleteMultipartUploadAsync(compRequest, cancellationToken) | ||||||
| var completeResponse = await this._s3Client.CompleteMultipartUploadAsync(compRequest, cancellationToken) | ||||||
| .ConfigureAwait(continueOnCapturedContext: false); | ||||||
| Logger.DebugFormat("Done completing multipart. ({0})", initResponse.UploadId); | ||||||
|
|
||||||
| var mappedResponse = ResponseMapper.MapCompleteMultipartUploadResponse(completeResponse); | ||||||
| FireTransferCompletedEvent(mappedResponse); | ||||||
| } | ||||||
| catch (Exception e) | ||||||
| { | ||||||
| Logger.Error(e, "Exception while uploading. ({0})", initResponse.UploadId); | ||||||
| Logger.Error(e, "Exception while uploading. ({0})", initResponse?.UploadId ?? "unknown"); | ||||||
|
|
||||||
| FireTransferFailedEvent(); | ||||||
|
|
||||||
| // Can't do async invocation in the catch block, doing cleanup synchronously. | ||||||
| Cleanup(initResponse.UploadId, pendingUploadPartTasks); | ||||||
|
||||||
| Cleanup(initResponse.UploadId, pendingUploadPartTasks); | |
| Cleanup(initResponse?.UploadId, pendingUploadPartTasks); |
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.
not sure if this is needed because initresponse could only be null if the initial request failed and if it did we throw exception above?
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.
we are also adding the request object to the progress args as part of this change