-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Migrate GcsOptions#getExecutorService to an unbounded ScheduledExecutorService #23545
Conversation
603f030
to
89819d7
Compare
R: @johnjcasey |
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control |
…orService This is a preliminary piece for issue apache#21368
Fixed spotbugs/fb warnings |
Run Java PreCommit |
I think this is good, but it is pretty complex. |
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.
A few questions, but looks good overall
threadFactoryBuilder.setThreadFactory(MoreExecutors.platformThreadFactory()); | ||
threadFactoryBuilder.setDaemon(true); | ||
|
||
this.threadPoolExecutor = |
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.
Given that we are basically wrapping a thread pool executor here, does it make sense to allow users to configure different TPEs?
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.
Eventually yes, but as an initial implementation I decided against it since it is easier to add features then remove them in the 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.
sounds good
@Override | ||
public Void call() throws Exception { | ||
while (true) { | ||
synchronized (tasks) { |
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.
because we sync on tasks here, is it possible for us to have late execution of a task that is intended to be submitted during this lock?
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 only sync on tasks
until we can pull out an entry and submit it to the executor.
Note that tasks.wait()
frees the monitor lock allowing other threads to synchronize on the tasks
monitor so the amount of time in the critical section is relatively short.
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.
makes sense
} | ||
|
||
@Override | ||
public void execute(Runnable command) { |
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 assume we can't use an @nonnull annotation because we are implementing a method?
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.
@nonnull
is the default by the way, we have to explicitly say something is @nullable
.
Also @nonnull
only adds checking for those that use that tooling when compiling their code.
The explicit check makes sure command
isn't null
for all those that don't use findbugs/spotbugs and to match the ScheduledExecutorService method contracts.
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.
makes sense
LTGM |
This is a preliminary piece for issue #21368
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
R: @username
).addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI.