Skip to content
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

[TM DownloadFile Pause and Resume] Part 3: Implement resumeDownloadFile #3157

Merged
merged 5 commits into from
Apr 14, 2022

Conversation

zoewangg
Copy link
Contributor

@zoewangg zoewangg commented Apr 12, 2022

Modifications

Implement S3TransferManager#resumeDownloadFile.

Below is the workflow for resume

1. Send HeadObjectRequest to retrieve the last modified time of the S3 object
2. Compare s3ObjectLastModified and fileLastModified to see if the file or the s3 object has been modified since last pause.
3. If either of them has been modified, the SDK will download the object from the beginning and replace the existing content in the file.
4. If neither of them has been modified, the SDK will start to download from the next byte

Testing

Added unit tests and functional tests

@zoewangg zoewangg requested a review from a team as a code owner April 12, 2022 20:14
Comment on lines 84 to 87
public static FileTransformerConfiguration defaultCreateOrReplaceExisting() {
return builder().fileWriteOption(FileWriteOption.CREATE_OR_REPLACE_EXISTING)
.failureBehavior(FailureBehavior.DELETE)
.failureBehavior(FailureBehavior.LEAVE)
.build();
Copy link
Contributor Author

@zoewangg zoewangg Apr 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had to change the default behavior for createOrReplaceExisting because always deleting a file upon exceptions would not work for resume (manifested as cancellation exception)

Another option is to move this method defaultCreateOrReplaceExisting along with defaultCreateOrAppend to s3-transfer-manager` and make them private APIs if we think this behavior is confusing.

WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I think this behavior is fine

Comment on lines -85 to -91
public String toString() {
return ToString.builder("ResumableFileDownload")
.add("downloadFileRequest", downloadFileRequest)
.add("bytesTransferred", bytesTransferred)
.add("lastModified", lastModified)
.add("transferSizeInBytes", transferSizeInBytes)
.build();
Copy link
Contributor Author

@zoewangg zoewangg Apr 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method will be implemented in a separate PR as part of serialization/deserialization APIs

@zoewangg zoewangg merged commit d05a8e3 into zoewang/tm-download-pause-resume Apr 14, 2022
@zoewangg zoewangg deleted the zoewang/tm-download-resume branch April 14, 2022 20:03
@sonarcloud
Copy link

sonarcloud bot commented Apr 14, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

81.9% 81.9% Coverage
0.0% 0.0% Duplication

zoewangg added a commit that referenced this pull request Apr 27, 2022
* [TM DownloadFile Pause and Resume] Part 1: Add configuration to enable overwriting existing files (#3125)

* Expose an option to overwrite an existing file in FileAsyncResponseTransformer

* Add changelog entries and make TM use CREATE_OR_REPLACE_EXISTING write option by default

* Address feedback

* Update and address feedback

* [TM DownloadFile Pause and Resume] Part 2: Implement pause for downloadFile operation (#3094)

* Part 1: Implement pause for downloadFile operation

* Address feedback

* Refactor the logic

* Address feedback

* Fix merging issue

* [TM DownloadFile Pause and Resume] Part 3: Implement resumeDownloadFile (#3157)

* Implement resumeDownloadFile

* Move test code around

* Address feedback

* Fix flaky test

* fix flaky integ test

* add changelog entry

* Troubleshooting flaky test

* Add file length check when checking if file has modified or not

* Address feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants