-
Notifications
You must be signed in to change notification settings - Fork 220
feat: use only one, configurable ExecutorService #546
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
Conversation
@@ -146,7 +124,13 @@ private void executeBufferedEvents(String customResourceUid) { | |||
latestCustomResource.get(), | |||
retryInfo(customResourceUid)); | |||
log.debug("Executing events for custom resource. Scope: {}", executionScope); | |||
executor.execute(new ExecutionConsumer(executionScope, eventDispatcher, this)); | |||
executor.execute(() -> { |
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.
Nice!
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.
Actually, I'm probably going to revert that change so that we can override toString
to get more precise debugging information on the Runnable… 🥲
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.
What I meant eliminating the ExecutionConsumer is elegant here
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.
Yes, I understood that but like I said, I actually need to re-introduce some equivalent form of it :)
executor.execute(new ExecutionConsumer(executionScope, eventDispatcher, this)); | ||
executor.execute(() -> { | ||
// change thread name for easier debugging | ||
Thread.currentThread().setName("EventHandler-" + controllerName); |
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.
Is this needed? It looks a bit strange that we change the thread name on every execution.
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.
Well, that was previously done when initializing the thread pool by specifying the thread factory. We can't do that anymore so the only alternative I could think of at that point was to rename the thread when it executes.
LGTM |
This would allow easier diagnosis when the thread is rejected.
97772a4
to
ef27cba
Compare
The goal is to make sure the thread pool is properly started and shut down at appropriate time, while getting it ready for instrumentation. This should also address the tests issue where the executor was shut down at the end of one test and never re-started at the beginning of the next one thus leading to tasks being rejected.
This is done by moving the close method to static and nulling the singleton so that it can be re-created on next Operator start if needed. This is needed for proper testing support.
Fixes #540
cc @lburgazzoli