@@ -75,23 +75,28 @@ public class ServerOptions {
7575 public static final int IO_THREADS =
7676 Integer .parseInt (
7777 System .getProperty (
78- "jooby.server.ioThreads" ,
79- Integer .toString (Runtime .getRuntime ().availableProcessors ())));
78+ "server.ioThreads" , Integer .toString (Runtime .getRuntime ().availableProcessors ())));
79+
80+ private static final String SERVER_NAME = System .getProperty ("server.name" );
8081
8182 /**
8283 * Number of worker (a.k.a application) threads. It is the number of processors multiply by <code>
8384 * 8</code>.
8485 */
85- public static final int WORKER_THREADS = Runtime .getRuntime ().availableProcessors () * 8 ;
86+ public static final int WORKER_THREADS =
87+ Integer .parseInt (
88+ System .getProperty (
89+ "server.workerThreads" ,
90+ Integer .toString (Runtime .getRuntime ().availableProcessors () * 8 )));
8691
8792 /** HTTP port. Default is <code>8080</code> or <code>0</code> for random port. */
8893 private int port = SERVER_PORT ;
8994
9095 /** Number of IO threads used by the server. Used by Netty and Undertow. */
91- private Integer ioThreads ;
96+ private int ioThreads = IO_THREADS ;
9297
9398 /** Number of worker threads (a.k.a application) to use. */
94- private Integer workerThreads ;
99+ private int workerThreads = WORKER_THREADS ;
95100
96101 /**
97102 * Configure server to default headers: <code>Date</code>, <code>Content-Type</code> and <code>
@@ -100,9 +105,9 @@ public class ServerOptions {
100105 private boolean defaultHeaders = true ;
101106
102107 /** Name of server: Jetty, Netty or Undertow. */
103- private String server ;
108+ private String server = SERVER_NAME ;
104109
105- private OutputOptions buffer = OutputOptions .defaults ();
110+ private OutputOptions output = OutputOptions .defaults ();
106111
107112 /**
108113 * Maximum request size in bytes. Request exceeding this value results in {@link
@@ -150,11 +155,11 @@ public class ServerOptions {
150155 if (conf .hasPath ("server.name" )) {
151156 options .setServer (conf .getString ("server.name" ));
152157 }
153- if (conf .hasPath ("server.buffer .size" )) {
154- options .buffer .setSize (conf .getInt ("server.buffer .size" ));
158+ if (conf .hasPath ("server.output .size" )) {
159+ options .output .setSize (conf .getInt ("server.output .size" ));
155160 }
156- if (conf .hasPath ("server.buffer .useDirectBuffers" )) {
157- options .buffer .setDirectBuffers (conf .getBoolean ("server.buffer .useDirectBuffers" ));
161+ if (conf .hasPath ("server.output .useDirectBuffers" )) {
162+ options .output .setDirectBuffers (conf .getBoolean ("server.output .useDirectBuffers" ));
158163 }
159164 if (conf .hasPath ("server.defaultHeaders" )) {
160165 options .setDefaultHeaders (conf .getBoolean ("server.defaultHeaders" ));
@@ -197,11 +202,9 @@ public String toString() {
197202 StringBuilder buff = new StringBuilder ();
198203 buff .append (Optional .ofNullable (server ).orElse ("server" )).append (" {" );
199204 buff .append ("port: " ).append (port );
200- if (!"jetty" .equals (server )) {
201- buff .append (", ioThreads: " ).append (Optional .ofNullable (ioThreads ).orElse (IO_THREADS ));
202- }
205+ buff .append (", ioThreads: " ).append (getIoThreads ());
203206 buff .append (", workerThreads: " ).append (getWorkerThreads ());
204- buff .append (", buffer : " ).append (getBuffer ());
207+ buff .append (", output : " ).append (getOutput ());
205208 buff .append (", maxRequestSize: " ).append (maxRequestSize );
206209 buff .append (", httpsOnly: " ).append (httpsOnly );
207210 if (compressionLevel != null ) {
@@ -311,17 +314,7 @@ public boolean isHttpsOnly() {
311314 * @return Number of IO threads used by the server. Required by Netty and Undertow.
312315 */
313316 public int getIoThreads () {
314- return getIoThreads (IO_THREADS );
315- }
316-
317- /**
318- * Number of IO threads used by the server. Required by Netty and Undertow.
319- *
320- * @param defaultIoThreads Default number of threads if none was set.
321- * @return Number of IO threads used by the server. Required by Netty and Undertow.
322- */
323- public int getIoThreads (int defaultIoThreads ) {
324- return ioThreads == null ? defaultIoThreads : ioThreads ;
317+ return ioThreads ;
325318 }
326319
327320 /**
@@ -343,19 +336,7 @@ public int getIoThreads(int defaultIoThreads) {
343336 * allowed to block.
344337 */
345338 public int getWorkerThreads () {
346- return getWorkerThreads (WORKER_THREADS );
347- }
348-
349- /**
350- * Number of worker threads (a.k.a application) to use. These are the threads which are allowed to
351- * block.
352- *
353- * @param defaultWorkerThreads Default worker threads is none was set.
354- * @return Number of worker threads (a.k.a application) to use. These are the threads which are
355- * allowed to block.
356- */
357- public int getWorkerThreads (int defaultWorkerThreads ) {
358- return workerThreads == null ? defaultWorkerThreads : workerThreads ;
339+ return workerThreads ;
359340 }
360341
361342 /**
@@ -415,12 +396,12 @@ public boolean getDefaultHeaders() {
415396 return this ;
416397 }
417398
418- public OutputOptions getBuffer () {
419- return buffer ;
399+ public OutputOptions getOutput () {
400+ return output ;
420401 }
421402
422- public ServerOptions setBuffer (@ NonNull OutputOptions buffer ) {
423- this .buffer = buffer ;
403+ public ServerOptions setOutput (@ NonNull OutputOptions output ) {
404+ this .output = output ;
424405 return this ;
425406 }
426407
0 commit comments