Set min/max threads for backup/storage service.

From https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html:
 When a new task is submitted in method execute(java.lang.Runnable),
 and fewer than corePoolSize threads are running, a new thread is
 created to handle the request, even if other worker threads are idle.
 If there are more than corePoolSize but less than maximumPoolSize
 threads running, a new thread will be created only if the queue is full.

Since we utilize an unbounded queue, we'll never hit the condition that
the queue is full, so the pool will never grow past corePoolSize.  Given
that, explicitly state that our max is 1 thread.  This should be a noop
operationally.

Thanks to https://github.com/dropwizard/dropwizard/pull/834 for building
in warnings to help us find this.
This commit is contained in:
Graeme Connell 2021-05-18 11:06:21 -06:00 committed by gram-signal
parent 0cd3640f13
commit aa65d34c36
1 changed files with 2 additions and 2 deletions

View File

@ -395,8 +395,8 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
ExecutorService keyspaceNotificationDispatchExecutor = environment.lifecycle().executorService(name(getClass(), "keyspaceNotification-%d")).maxThreads(16).workQueue(keyspaceNotificationDispatchQueue).build();
ExecutorService apnSenderExecutor = environment.lifecycle().executorService(name(getClass(), "apnSender-%d")).maxThreads(1).minThreads(1).build();
ExecutorService gcmSenderExecutor = environment.lifecycle().executorService(name(getClass(), "gcmSender-%d")).maxThreads(1).minThreads(1).build();
ExecutorService backupServiceExecutor = environment.lifecycle().executorService(name(getClass(), "backupService-%d")).maxThreads(8).minThreads(1).build();
ExecutorService storageServiceExecutor = environment.lifecycle().executorService(name(getClass(), "storageService-%d")).maxThreads(8).minThreads(1).build();
ExecutorService backupServiceExecutor = environment.lifecycle().executorService(name(getClass(), "backupService-%d")).maxThreads(1).minThreads(1).build();
ExecutorService storageServiceExecutor = environment.lifecycle().executorService(name(getClass(), "storageService-%d")).maxThreads(1).minThreads(1).build();
ExecutorService torExitNodeExecutor = environment.lifecycle().executorService(name(getClass(), "torExitNode-%d")).maxThreads(1).minThreads(1).build();
ExecutorService donationExecutor = environment.lifecycle().executorService(name(getClass(), "donation-%d")).maxThreads(1).minThreads(1).build();