Externalize httpd and sshd thread computation

Move sshd.threads, httpd.maxThreads and database.poolLimit to separate
class. This way default value of poolLimit can be dynamically computed
based on two previously mentioned properties.

Change-Id: I5167c4a42ed5e5a480d0ff4accba490dffa05fd4
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
This commit is contained in:
Dariusz Luksza
2015-11-09 20:25:25 +01:00
parent d058b5da0c
commit 2ebfc28b4b
7 changed files with 87 additions and 18 deletions

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.sshd;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.ThreadSettingsConfig;
import com.google.gerrit.server.git.QueueProvider;
import com.google.gerrit.server.git.WorkQueue;
import com.google.inject.Inject;
@@ -31,11 +32,13 @@ public class CommandExecutorQueueProvider implements QueueProvider {
private final WorkQueue.Executor batchExecutor;
@Inject
public CommandExecutorQueueProvider(@GerritServerConfig final Config config,
final WorkQueue queues) {
final int cores = Runtime.getRuntime().availableProcessors();
poolSize = config.getInt("sshd", "threads", 3 * cores / 2);
batchThreads = config.getInt("sshd", "batchThreads", cores == 1 ? 1 : 2);
public CommandExecutorQueueProvider(
@GerritServerConfig Config config,
ThreadSettingsConfig threadsSettingsConfig,
WorkQueue queues) {
poolSize = threadsSettingsConfig.getSshdThreads();
batchThreads = config.getInt("sshd", "batchThreads",
threadsSettingsConfig.getSshdBatchTreads());
if (batchThreads > poolSize) {
poolSize += batchThreads;
}