-
Notifications
You must be signed in to change notification settings - Fork 909
[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
[TM DownloadDirectory Part3] Various updates on downloadDirectory #3020
Conversation
…t download file 2. create nonexistent parent directories 3. normalize key if prefix is not empty
…to zoewang/tm-downloadDirectoryPart3
...nager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DownloadDirectoryHelper.java
Outdated
Show resolved
Hide resolved
*/ | ||
private static String normalizeKey(DownloadDirectoryRequest downloadDirectoryRequest, S3Object s3Object, | ||
String delimiter) { | ||
return downloadDirectoryRequest.prefix() |
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.
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);
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 not sure if it's possible to define a regex because we don't know the length of the prefix beforehand.
...nager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DownloadDirectoryHelper.java
Outdated
Show resolved
Hide resolved
...nager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DownloadDirectoryHelper.java
Outdated
Show resolved
Hide resolved
...nager/src/main/java/software/amazon/awssdk/transfer/s3/internal/DownloadDirectoryHelper.java
Outdated
Show resolved
Hide resolved
core/sdk-core/src/main/java/software/amazon/awssdk/core/async/SdkPublisher.java
Outdated
Show resolved
Hide resolved
@SdkProtectedApi | ||
public class AsyncBufferingSubscriber<T> implements Subscriber<T> { | ||
private static final Logger log = Logger.loggerFor(AsyncBufferingSubscriber.class); | ||
private final Event<T> completeEvent = new CompleteEvent<>(); |
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.
Nit: Can be static?
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.
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; |
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.
Nit: Possible to use a more specific name, like endOfStreamFuture
?
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.
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; |
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.
Should we return here? If this is unsupported behavior, should we throw or log a warning?
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.
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.
utils/src/main/java/software/amazon/awssdk/utils/async/AsyncBufferingSubscriber.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/async/AsyncBufferingSubscriber.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/async/AsyncBufferingSubscriber.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/async/AsyncBufferingSubscriber.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/async/AsyncBufferingSubscriber.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/async/AsyncBufferingSubscriber.java
Outdated
Show resolved
Hide resolved
...ager/src/main/java/software/amazon/awssdk/transfer/s3/internal/AsyncBufferingSubscriber.java
Outdated
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed! |
* [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)
Modifications
Testing
Added unit tests
Screenshots (if appropriate)
Types of changes
Checklist
mvn install
succeedsscripts/new-change
script and following the instructions. Commit the new file created by the script in.changes/next-release
with your changes.License