Skip to content

Commit 76ef8d3

Browse files
DaanHooglandAhmed AwlaqiDaan Hoogland
authored
make server threads configurable with server.properties file (#11540)
Co-authored-by: Ahmed Awlaqi <ahmed.awlaqi@sue.nl> Co-authored-by: Daan Hoogland <dahn@apache.org>
1 parent abe41ad commit 76ef8d3

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

client/conf/server.properties.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@ access.log=/var/log/cloudstack/management/access.log
5858

5959
# The deployment mode for the extensions
6060
extensions.deployment.mode=@EXTENSIONSDEPLOYMENTMODE@
61+
62+
# Thread pool configuration
63+
#threads.min=10
64+
#threads.max=500

client/src/main/java/org/apache/cloudstack/ServerDaemon.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public class ServerDaemon implements Daemon {
8686
private static final int DEFAULT_REQUEST_CONTENT_SIZE = 1048576;
8787
private static final String REQUEST_MAX_FORM_KEYS_KEY = "request.max.form.keys";
8888
private static final int DEFAULT_REQUEST_MAX_FORM_KEYS = 5000;
89+
private static final String THREADS_MIN = "threads.min";
90+
private static final String THREADS_MAX = "threads.max";
8991

9092
////////////////////////////////////////////////////////
9193
/////////////// Server Configuration ///////////////////
@@ -106,6 +108,8 @@ public class ServerDaemon implements Daemon {
106108
private String keystoreFile;
107109
private String keystorePassword;
108110
private String webAppLocation;
111+
private int minThreads;
112+
private int maxThreads;
109113

110114
//////////////////////////////////////////////////
111115
/////////////// Public methods ///////////////////
@@ -147,6 +151,8 @@ public void init(final DaemonContext context) {
147151
setSessionTimeout(Integer.valueOf(properties.getProperty(SESSION_TIMEOUT, "30")));
148152
setMaxFormContentSize(Integer.valueOf(properties.getProperty(REQUEST_CONTENT_SIZE_KEY, String.valueOf(DEFAULT_REQUEST_CONTENT_SIZE))));
149153
setMaxFormKeys(Integer.valueOf(properties.getProperty(REQUEST_MAX_FORM_KEYS_KEY, String.valueOf(DEFAULT_REQUEST_MAX_FORM_KEYS))));
154+
setMinThreads(Integer.valueOf(properties.getProperty(THREADS_MIN, "10")));
155+
setMaxThreads(Integer.valueOf(properties.getProperty(THREADS_MAX, "500")));
150156
} catch (final IOException e) {
151157
logger.warn("Failed to read configuration from server.properties file", e);
152158
} finally {
@@ -164,8 +170,8 @@ public void init(final DaemonContext context) {
164170
public void start() throws Exception {
165171
// Thread pool
166172
final QueuedThreadPool threadPool = new QueuedThreadPool();
167-
threadPool.setMinThreads(10);
168-
threadPool.setMaxThreads(500);
173+
threadPool.setMinThreads(minThreads);
174+
threadPool.setMaxThreads(maxThreads);
169175

170176
// Jetty Server
171177
server = new Server(threadPool);
@@ -394,4 +400,12 @@ public void setMaxFormContentSize(int maxFormContentSize) {
394400
public void setMaxFormKeys(int maxFormKeys) {
395401
this.maxFormKeys = maxFormKeys;
396402
}
403+
404+
public void setMinThreads(int minThreads) {
405+
this.minThreads = minThreads;
406+
}
407+
408+
public void setMaxThreads(int maxThreads) {
409+
this.maxThreads = maxThreads;
410+
}
397411
}

0 commit comments

Comments
 (0)