public class ServerOptions extends Object
Modifier and Type | Field and Description |
---|---|
static int |
_10MB
10mb constant in bytes.
|
static int |
_16KB
16kb constant in bytes.
|
static int |
_4KB
4kb constant in bytes.
|
static int |
_8KB
8kb constant in bytes.
|
static int |
DEFAULT_PORT
Default application port
8080 or the value of system property server.port . |
static int |
IO_THREADS
Number of available threads, but never smaller than
2 . |
static int |
WORKER_THREADS
Number of worker (a.k.a application) threads.
|
Constructor and Description |
---|
ServerOptions() |
Modifier and Type | Method and Description |
---|---|
static Optional<ServerOptions> |
from(com.typesafe.config.Config conf)
Creates server options from config object.
|
int |
getBufferSize()
Server buffer size in bytes.
|
boolean |
getDefaultHeaders()
True if default headers:
Date , Content-Type and Server
are enabled. |
boolean |
getGzip()
True if gzip is enabled.
|
int |
getIoThreads()
Number of IO threads used by the server.
|
int |
getIoThreads(int defaultIoThreads)
Number of IO threads used by the server.
|
int |
getMaxRequestSize()
Maximum request size in bytes.
|
int |
getPort()
Server HTTP port.
|
String |
getServer()
Server name.
|
int |
getWorkerThreads()
Number of worker threads (a.k.a application) to use.
|
int |
getWorkerThreads(int defaultWorkerThreads)
Number of worker threads (a.k.a application) to use.
|
ServerOptions |
setBufferSize(int bufferSize)
Set buffer size.
|
ServerOptions |
setDefaultHeaders(boolean defaultHeaders)
Enabled/disabled default server headers:
Date , Content-Type and
Server . |
ServerOptions |
setGzip(boolean gzip)
Enabled/disabled gzip.
|
ServerOptions |
setIoThreads(int ioThreads)
Set number of IO threads to use.
|
ServerOptions |
setMaxRequestSize(int maxRequestSize)
Set max request size in bytes.
|
ServerOptions |
setPort(int port)
Set the server port (default is 8080).
|
ServerOptions |
setServer(String server)
Set server name.
|
ServerOptions |
setWorkerThreads(int workerThreads)
Set number of worker threads (a.k.a application) to use.
|
String |
toString() |
public static final int DEFAULT_PORT
8080
or the value of system property server.port
.public static final int _4KB
public static final int _8KB
public static final int _16KB
public static final int _10MB
public static final int IO_THREADS
2
.public static final int WORKER_THREADS
8
.@Nonnull public static Optional<ServerOptions> from(@Nonnull com.typesafe.config.Config conf)
server.port
, server.ioThreads
, etc...conf
- Configuration object.@Nonnull public ServerOptions setServer(@Nonnull String server)
server
- Name of the underlying server.public int getPort()
@Nonnull public ServerOptions setPort(int port)
0
.port
- Server port or 0
to pick a random port.public int getIoThreads()
public int getIoThreads(int defaultIoThreads)
defaultIoThreads
- Default number of threads if none was set.@Nonnull public ServerOptions setIoThreads(int ioThreads)
ioThreads
- Number of threads. Must be greater than 0
.public int getWorkerThreads()
public int getWorkerThreads(int defaultWorkerThreads)
defaultWorkerThreads
- Default worker threads is none was set.@Nonnull public ServerOptions setWorkerThreads(int workerThreads)
workerThreads
- Number of worker threads to use.public boolean getGzip()
@Nonnull public ServerOptions setGzip(boolean gzip)
gzip
- True to enabled it. Default is disabled(false).public boolean getDefaultHeaders()
Date
, Content-Type
and Server
are enabled.Date
, Content-Type
and
Server
are enabled.@Nonnull public ServerOptions setDefaultHeaders(boolean defaultHeaders)
Date
, Content-Type
and
Server
. Enabled by default.defaultHeaders
- True for enabled.public int getBufferSize()
16kb
. Used for reading/writing data.16kb
. Used for reading/writing
data.@Nonnull public ServerOptions setBufferSize(int bufferSize)
bufferSize
- Buffer size.public int getMaxRequestSize()
StatusCode.REQUEST_ENTITY_TOO_LARGE
response. Default is 10mb
.@Nonnull public ServerOptions setMaxRequestSize(int maxRequestSize)
maxRequestSize
- Max request size in bytes.Copyright © 2019. All rights reserved.