-
Notifications
You must be signed in to change notification settings - Fork 1.3k
make server threads configurable with server.properties file #9260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -82,6 +82,8 @@ public class ServerDaemon implements Daemon { | |||||||||
| private static final String ACCESS_LOG = "access.log"; | ||||||||||
| private static final String REQUEST_CONTENT_SIZE_KEY = "request.content.size"; | ||||||||||
| private static final int DEFAULT_REQUEST_CONTENT_SIZE = 1048576; | ||||||||||
| private static final String THREADS_MIN = "threads.min"; | ||||||||||
| private static final String THREADS_MAX = "threads.max"; | ||||||||||
|
|
||||||||||
| //////////////////////////////////////////////////////// | ||||||||||
| /////////////// Server Configuration /////////////////// | ||||||||||
|
|
@@ -101,6 +103,8 @@ public class ServerDaemon implements Daemon { | |||||||||
| private String keystoreFile; | ||||||||||
| private String keystorePassword; | ||||||||||
| private String webAppLocation; | ||||||||||
| private int minThreads = 10; | ||||||||||
| private int maxThreads = 500; | ||||||||||
|
Comment on lines
+106
to
+107
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a small a nitpick, but you don't need to initialize these values, as in the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will you change this @ahmedali6 ? No big deal if you don't, but if you do, you can also comment out the new properties for the same reason.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| ////////////////////////////////////////////////// | ||||||||||
| /////////////// Public methods /////////////////// | ||||||||||
|
|
@@ -141,6 +145,8 @@ public void init(final DaemonContext context) { | |||||||||
| setAccessLogFile(properties.getProperty(ACCESS_LOG, "access.log")); | ||||||||||
| setSessionTimeout(Integer.valueOf(properties.getProperty(SESSION_TIMEOUT, "30"))); | ||||||||||
| setMaxFormContentSize(Integer.valueOf(properties.getProperty(REQUEST_CONTENT_SIZE_KEY, String.valueOf(DEFAULT_REQUEST_CONTENT_SIZE)))); | ||||||||||
| setMinThreads(Integer.valueOf(properties.getProperty(THREADS_MIN, "10"))); | ||||||||||
| setMaxThreads(Integer.valueOf(properties.getProperty(THREADS_MAX, "500"))); | ||||||||||
| } catch (final IOException e) { | ||||||||||
| logger.warn("Failed to read configuration from server.properties file", e); | ||||||||||
| } finally { | ||||||||||
|
|
@@ -158,8 +164,8 @@ public void init(final DaemonContext context) { | |||||||||
| public void start() throws Exception { | ||||||||||
| // Thread pool | ||||||||||
| final QueuedThreadPool threadPool = new QueuedThreadPool(); | ||||||||||
| threadPool.setMinThreads(10); | ||||||||||
| threadPool.setMaxThreads(500); | ||||||||||
| threadPool.setMinThreads(minThreads); | ||||||||||
| threadPool.setMaxThreads(maxThreads); | ||||||||||
|
|
||||||||||
| // Jetty Server | ||||||||||
| server = new Server(threadPool); | ||||||||||
|
|
@@ -366,4 +372,12 @@ public void setSessionTimeout(int sessionTimeout) { | |||||||||
| public void setMaxFormContentSize(int maxFormContentSize) { | ||||||||||
| this.maxFormContentSize = maxFormContentSize; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public void setMinThreads(int minThreads) { | ||||||||||
| this.minThreads = minThreads; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public void setMaxThreads(int maxThreads) { | ||||||||||
| this.maxThreads = maxThreads; | ||||||||||
| } | ||||||||||
| } | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor - too many places we are setting the default value. This could have been a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.