Skip to content

[TM DownloadDirectory Part3] Various updates on downloadDirectory #3020

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

Merged

Conversation

zoewangg
Copy link
Contributor

@zoewangg zoewangg commented Feb 9, 2022

Modifications

Testing

Added unit tests

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@zoewangg zoewangg requested a review from a team as a code owner February 9, 2022 22:11
*/
private static String normalizeKey(DownloadDirectoryRequest downloadDirectoryRequest, S3Object s3Object,
String delimiter) {
return downloadDirectoryRequest.prefix()
Copy link
Contributor

Choose a reason for hiding this comment

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

NonBlocker , just suggestion :
was curious if we can use regex for this , something like ^(.+)\/([^\/]+)$ where / 6th character is the delimiter

String regexExpression = String.format("^(.+)\\%s([^\\/]+)$", delimiter);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if it's possible to define a regex because we don't know the length of the prefix beforehand.

@SdkProtectedApi
public class AsyncBufferingSubscriber<T> implements Subscriber<T> {
private static final Logger log = Logger.loggerFor(AsyncBufferingSubscriber.class);
private final Event<T> completeEvent = new CompleteEvent<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can be static?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generic can't be used in a static field. :(

private static final Logger log = Logger.loggerFor(AsyncBufferingSubscriber.class);
private final Event<T> completeEvent = new CompleteEvent<>();
private final Queue<Event<T>> buffer;
private final CompletableFuture<?> future;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Possible to use a more specific name, like endOfStreamFuture?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this future actually finishes after all futures are finished(not end of stream). I'll rename it

Validate.paramNotNull(subscription, "subscription");
if (this.subscription != null) {
subscription.cancel();
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we return here? If this is unsupported behavior, should we throw or log a warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, per reactive streams spec, we must call subscription.cancel. I can add a logging statement there

A Subscriber MUST call Subscription.cancel() on the given Subscription after an onSubscribe signal if it already has an active Subscription.

@sonarqubecloud
Copy link

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 22 Code Smells

82.4% 82.4% Coverage
2.6% 2.6% Duplication

@zoewangg zoewangg merged commit 33b1be1 into zoewang/tm-downloadDirectory Feb 14, 2022
@zoewangg zoewangg deleted the zoewang/tm-downloadDirectoryPart3 branch February 14, 2022 21:49
zoewangg added a commit that referenced this pull request Feb 15, 2022
* [TM DownloadDirectory Part1] Create POJO classes for download directory (#2993)

* Create POJO classes for download directory

* Address feedback

* Address comments

* A couple of minor refactoring on the S3TransferManager (#2997)

* [TM DownloadDirectory Part2] Implement download directory in transfer manager (#3010)

* Implement download directory in transfer manager

* Add more tests and address comments

* Remove create parent directories logic and add changelog entry

* [TM DownloadDirectory Part3] Various updates on downloadDirectory (#3020)

* Implement download directory in transfer manager

* Add more tests and address comments

* Remove create parent directories logic and add changelog entry

* Various updates on downloadDirectory 1. limit the number of concurrent download file 2. create nonexistent parent directories 3. normalize key if prefix is not empty

* By default, set delimiter to null to avoid potentially excessive listObjectsV2 calls

* Move async buffering logic to SdkPublisher

* Move AsyncBufferingSubscriber back to s3-tranfer-manager module and address feedback

* remove unnecessary isDelivering.set(false)
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.

4 participants