Skip to content

Commit

Permalink
fix: Log HttpJson's async thread pool core size (#2697)
Browse files Browse the repository at this point in the history
Fixes #2680
  • Loading branch information
lqiu96 authored Apr 30, 2024
1 parent 208bef4 commit 34b4bc3
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* InstantiatingChannelProvider is an ExecutorProvider which constructs a new
* ScheduledExecutorService every time getExecutor() is called.
*/
@AutoValue
public abstract class InstantiatingExecutorProvider implements ExecutorProvider {
private static final Logger LOGGER =
Logger.getLogger(InstantiatingExecutorProvider.class.getName());

// Thread factory to use to create our worker threads
private static final ThreadFactory DEFAULT_THREAD_FACTORY =
new ThreadFactory() {
Expand Down Expand Up @@ -95,6 +100,8 @@ public static Builder newBuilder() {
public static Builder newIOBuilder() {
int numCpus = Runtime.getRuntime().availableProcessors();
int numThreads = IO_THREAD_MULTIPLIER * Math.max(MIN_THREAD_AMOUNT, numCpus);
LOGGER.log(
Level.CONFIG, String.format("Thread Pool for requests has Core Pool Size: %d", numThreads));

return new AutoValue_InstantiatingExecutorProvider.Builder()
.setExecutorThreadCount(numThreads)
Expand Down

0 comments on commit 34b4bc3

Please sign in to comment.