Jackie-Jiang commented on code in PR #13360: URL: https://github.com/apache/pinot/pull/13360#discussion_r1635274958
########## pinot-common/src/main/java/org/apache/pinot/common/utils/ScalingThreadPoolExecutor.java: ########## @@ -100,29 +100,42 @@ public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { */ static class ScalingQueue<E> extends LinkedBlockingQueue<E> { - private ThreadPoolExecutor _executor; + AtomicInteger _currentIdleThreadCount = new AtomicInteger(0); // Creates a queue of size Integer.MAX_SIZE public ScalingQueue() { super(); } - // Sets the executor this queue belongs to - public void setThreadPoolExecutor(ThreadPoolExecutor executor) { - _executor = executor; + @Override + @Nonnull Review Comment: We don't usually annotate `@Nonnull` but assume everything is non-null if not annotated. Can you remove this and annotate `poll()` return as `@Nullable` instead? ########## pinot-common/src/main/java/org/apache/pinot/common/utils/ScalingThreadPoolExecutor.java: ########## @@ -100,29 +100,42 @@ public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { */ static class ScalingQueue<E> extends LinkedBlockingQueue<E> { - private ThreadPoolExecutor _executor; + AtomicInteger _currentIdleThreadCount = new AtomicInteger(0); // Creates a queue of size Integer.MAX_SIZE public ScalingQueue() { super(); } - // Sets the executor this queue belongs to - public void setThreadPoolExecutor(ThreadPoolExecutor executor) { - _executor = executor; + @Override + @Nonnull + public E take() + throws InterruptedException { + _currentIdleThreadCount.incrementAndGet(); + E e = super.take(); + _currentIdleThreadCount.decrementAndGet(); Review Comment: Suggest putting it within `try-finally` because `take()` can throw exception. Same for `poll()` -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org