GWphua commented on code in PR #19433:
URL: https://github.com/apache/druid/pull/19433#discussion_r3208069546
##########
extensions-core/kubernetes-overlord-extensions/src/main/java/org/apache/druid/k8s/overlord/KubernetesTaskRunner.java:
##########
@@ -146,9 +161,28 @@
this.emitter = emitter;
this.currentCapacity = new AtomicInteger(config.getCapacity());
- this.tpe = new ThreadPoolExecutor(currentCapacity.get(),
currentCapacity.get(), 0L, TimeUnit.MILLISECONDS, new
LinkedBlockingQueue<Runnable>(), Execs.makeThreadFactory("k8s-task-runner-%d",
null));
+ if (sharedExecutor == null) {
+ this.tpe = new ThreadPoolExecutor(
+ currentCapacity.get(),
+ currentCapacity.get(),
+ 0L,
+ TimeUnit.MILLISECONDS,
+ new LinkedBlockingQueue<Runnable>(),
+ Execs.makeThreadFactory("k8s-task-runner-%d", null)
+ );
+ this.ownsExecutor = true;
+ } else {
+ this.tpe = sharedExecutor;
+ this.ownsExecutor = false;
+ }
this.exec = MoreExecutors.listeningDecorator(this.tpe);
- configManager.addListener(KubernetesTaskRunnerDynamicConfig.CONFIG_KEY,
StringUtils.format(OBSERVER_KEY, Thread.currentThread().getId()),
this::syncCapacityWithDynamicConfig);
+ if (ownsExecutor && configManager != null) {
+ configManager.addListener(
+ KubernetesTaskRunnerDynamicConfig.CONFIG_KEY,
+ StringUtils.format(OBSERVER_KEY, Thread.currentThread().getId()),
Review Comment:
The updated `Thread.threadId` is the replacement, introduced in Java 19. I
didn't get to see any PR that drops jdk17 support yet, (correct me if im
wrong), so we should still use this deprecated method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]