Class JettyServerHelper
- Direct Known Subclasses:
HttpServerHelper,HttpsServerHelper
| Parameter name | Value type | Default value | Description |
|---|---|---|---|
| threadPool.minThreads | int | 8 | Thread pool minimum threads |
| threadPool.maxThreads | int | 200 | Thread pool max threads |
| threadPool.threadsPriority | int | Thread.NORM_PRIORITY |
Thread pool threads priority |
| threadPool.idleTimeout | int | 60000 | Thread pool idle timeout in milliseconds; threads that are idle for longer than this period may be stopped |
| threadPool.stopTimeout | long | 5000 | Thread pool stop timeout in milliseconds; the maximum time allowed for the service to shutdown |
| connector.acceptors | int | -1 | Connector acceptor thread count; when -1, Jetty will default to 1 |
| connector.selectors | int | -1 | Connector selector thread count; When less or equal than 0, Jetty computes a default value derived from a heuristic over available CPUs and thread pool size. |
| connector.acceptQueueSize | int | 0 | Connector accept queue size; also known as accept backlog |
| connector.idleTimeout | int | 30000 | Connector idle timeout in milliseconds; see
Socket.setSoTimeout(int); this value is interpreted as the maximum
time between some progress being made on the connection; so if a single byte
is read or written, then the timeout is reset |
| connector.stopTimeout | long | 30000 | Connector stop timeout in milliseconds; the maximum time allowed for the service to shutdown |
| http.headerCacheSize | int | 512 | HTTP header cache size in bytes |
| http.requestHeaderSize | int | 8*1024 | HTTP request header size in bytes; larger headers will allow for more and/or larger cookies plus larger form content encoded in a URL; however, larger headers consume more memory and can make a server more vulnerable to denial of service attacks |
| http.responseHeaderSize | int | 8*1024 | HTTP response header size in bytes; larger headers will allow for more and/or larger cookies and longer HTTP headers (e.g. for redirection); however, larger headers will also consume more memory |
| http.outputBufferSize | int | 32*1024 | HTTP output buffer size in bytes; a larger buffer can improve performance by allowing a content producer to run without blocking, however larger buffers consume more memory and may induce some latency before a client starts processing the content |
| lowResource.period | int | 1000 | Low-resource monitor period in milliseconds; when 0, low-resource monitoring is disabled |
| lowResource.threads | boolean | true | Low-resource monitor, whether to check if we're low on threads |
| lowResource.maxMemory | int | 0 | Low-resource monitor max memory in bytes; when 0, the check disabled; memory used is calculated as (totalMemory-freeMemory) |
| lowResource.idleTimeout | int | 1000 | Low-resource monitor idle timeout in milliseconds; applied to EndPoints when in the low-resources state |
| server.maxConnections | int | 0 | Server max connections; when 0, there is no limit |
| server.maxConnections.idleTimeout | long | 0 | The endpoint idle timeout in milliseconds to apply when the connection limit is reached; when 0, there is no idle timeout. |
| shutdown.gracefully | boolean | true | When true, upon JVM shutdown, the Jetty server will block incoming requests and wait for pending requests to end before shutting down. Otherwise, incoming requests are not blocked and all requests are aborted. |
| shutdown.timeout | long | 30000 | Server shutdown timeout in milliseconds. Defaults to 30000. |
- Author:
- Jerome Louvel, Tal Liron
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract org.eclipse.jetty.server.ConnectionFactory[]createConnectionFactories(org.eclipse.jetty.server.HttpConfiguration configuration) Creates new internal Jetty connection factories.protected abstract List<org.eclipse.jetty.server.Connector> createConnectors(org.eclipse.jetty.server.Server server) Creates the Jetty connectors.protected org.eclipse.jetty.server.HttpConfigurationCreates a Jetty HTTP configuration.protected org.eclipse.jetty.server.ServerConnectorcreateServerConnector(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.HttpConfiguration configuration) Creates a Jetty connector based on a classical TCP type of transport.intConnector acceptor thread count.intConnector "accept" queue size.org.eclipse.jetty.io.ByteBufferPoolConnector byte buffer pool.Connector executor.intConnector idle timeout in milliseconds.org.eclipse.jetty.util.thread.SchedulerConnector scheduler.intConnector selector thread count.intHTTP header cache size in bytes.intHTTP output buffer size in bytes.intHTTP request header size in bytes.intHTTP response header size in bytes.intLow-resource monitor idle timeout in milliseconds.longLow-resource monitor max memory in bytes.intLow-resource monitor period in milliseconds.booleanLow-resource monitor, whether to check if we're low on threads.intServer max connections.longThe endpoint idle timeout in milliseconds to apply when the connection limit is reached.booleanWhen true, upon JVM shutdown, the Jetty server will block incoming requests and wait for pending requests to end before shutting down.longServer shutdown timeout in milliseconds.intThread pool idle timeout in milliseconds.intThread pool maximum threads.intThread pool minimum threads.longThread pool stop timeout in milliseconds.intThread pool threads priority.protected org.eclipse.jetty.server.ServerReturns the wrapped Jetty server.protected voidsetWrappedServer(org.eclipse.jetty.server.Server wrappedServer) Sets the wrapped Jetty server.voidstart()Start callback.voidstop()Stop callback.Methods inherited from class org.restlet.engine.adapter.HttpServerHelper
getAdapter, handle, setAdapterMethods inherited from class org.restlet.engine.connector.ServerHelper
handle, setEphemeralPort, setEphemeralPortMethods inherited from class org.restlet.engine.connector.ConnectorHelper
getConnectorService, getContext, getProtocols, updateMethods inherited from class org.restlet.engine.RestletHelper
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped
-
Constructor Details
-
JettyServerHelper
Constructor.- Parameters:
server- The server to help.
-
-
Method Details
-
createHttpConfiguration
protected org.eclipse.jetty.server.HttpConfiguration createHttpConfiguration()Creates a Jetty HTTP configuration.- Returns:
- A Jetty HTTP configuration.
-
createConnectionFactories
protected abstract org.eclipse.jetty.server.ConnectionFactory[] createConnectionFactories(org.eclipse.jetty.server.HttpConfiguration configuration) Creates new internal Jetty connection factories.- Parameters:
configuration- The HTTP configuration.- Returns:
- New internal Jetty connection factories.
-
createConnectors
protected abstract List<org.eclipse.jetty.server.Connector> createConnectors(org.eclipse.jetty.server.Server server) Creates the Jetty connectors.- Parameters:
server- The Jetty server.- Returns:
- The Jetty connectors.
-
createServerConnector
protected org.eclipse.jetty.server.ServerConnector createServerConnector(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.HttpConfiguration configuration) Creates a Jetty connector based on a classical TCP type of transport.- Parameters:
server- The Jetty server.- Returns:
- A Jetty connector.
-
getConnectorAcceptors
public int getConnectorAcceptors()Connector acceptor thread count. Defaults to -1. When -1, Jetty will default to 1.- Returns:
- Connector acceptor thread count.
-
getConnectorAcceptQueueSize
public int getConnectorAcceptQueueSize()Connector "accept" queue size. Defaults to 0.Also known as "accept" backlog.
- Returns:
- Connector accept queue size.
-
getConnectorByteBufferPool
public org.eclipse.jetty.io.ByteBufferPool getConnectorByteBufferPool()Connector byte buffer pool. Defaults to null. When null, will use a newArrayByteBufferPool.- Returns:
- Connector byte buffer pool or null.
-
getConnectorExecutor
Connector executor. Defaults to null. When null, will use the server's thread pool.- Returns:
- Connector executor or null.
-
getConnectorIdleTimeout
public int getConnectorIdleTimeout()Connector idle timeout in milliseconds. Defaults to 30000.This value is interpreted as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout is reset.
- Returns:
- Connector idle timeout.
-
getConnectorScheduler
public org.eclipse.jetty.util.thread.Scheduler getConnectorScheduler()Connector scheduler. Defaults to null. When null, will use a newScheduledExecutorScheduler.- Returns:
- Connector scheduler or null.
-
getConnectorSelectors
public int getConnectorSelectors()Connector selector thread count. Defaults to -1. When less or equal than 0, Jetty computes a default value derived from a heuristic over available CPUs and thread pool size.- Returns:
- Connector acceptor thread count.
-
getHttpHeaderCacheSize
public int getHttpHeaderCacheSize()HTTP header cache size in bytes. Defaults to 512.- Returns:
- HTTP header cache size.
-
getHttpOutputBufferSize
public int getHttpOutputBufferSize()HTTP output buffer size in bytes. Defaults to 32*1024.A larger buffer can improve performance by allowing a content producer to run without blocking, however, larger buffers consume more memory and may induce some latency before a client starts processing the content.
- Returns:
- HTTP output buffer size.
-
getHttpRequestHeaderSize
public int getHttpRequestHeaderSize()HTTP request header size in bytes. Defaults to 8*1024.Larger headers will allow for more and/or larger cookies plus larger form content encoded in a URL. However, larger headers consume more memory and can make a server more vulnerable to denial of service attacks.
- Returns:
- HTTP request header size.
-
getHttpResponseHeaderSize
public int getHttpResponseHeaderSize()HTTP response header size in bytes. Defaults to 8*1024.Larger headers will allow for more and/or larger cookies and longer HTTP headers (e.g., for redirection). However, larger headers will also consume more memory.
- Returns:
- HTTP response header size.
-
getLowResourceMonitorIdleTimeout
public int getLowResourceMonitorIdleTimeout()Low-resource monitor idle timeout in milliseconds. Defaults to 1000.Applied to EndPoints when in the low-resources state.
- Returns:
- Low-resource monitor idle timeout.
-
getLowResourceMonitorMaxMemory
public long getLowResourceMonitorMaxMemory()Low-resource monitor max memory in bytes. Defaults to 0. When 0, the check is disabled.Memory used is calculated as (totalMemory-freeMemory).
- Returns:
- Low-resource monitor max memory.
-
getLowResourceMonitorPeriod
public int getLowResourceMonitorPeriod()Low-resource monitor period in milliseconds. Defaults to 1000. When 0, low-resource monitoring is disabled.- Returns:
- Low-resource monitor period.
-
getLowResourceMonitorThreads
public boolean getLowResourceMonitorThreads()Low-resource monitor, whether to check if we're low on threads. Defaults to true.- Returns:
- Low-resource monitor threads.
-
getServerMaxConnections
public int getServerMaxConnections()Server max connections. Defaults to 0. When 0, the check is disabled.- Returns:
- Low-resource monitor max connections.
-
getServerMaxConnectionsIdleTimeout
public long getServerMaxConnectionsIdleTimeout()The endpoint idle timeout in milliseconds to apply when the connection limit is reached. Defaults to 0. When 0, there is no idle timeout.The maximum time allowed for the endpoint to close when the connection limit is reached.
- Returns:
- The endpoint idle timeout in milliseconds to apply when the connection limit is reached.
-
getShutdownGracefully
public boolean getShutdownGracefully()When true, upon JVM shutdown, the Jetty server will block incoming requests and wait for pending requests to end before shutting down. Otherwise, incoming requests are not blocked and all requests are aborted. Defaults to true.- Returns:
- True if upon JVM shutdown, the Jetty server will block incoming requests and wait for pending requests to end before shutting down. Otherwise, incoming requests are not blocked and all requests are aborted.
-
getShutdownTimeout
public long getShutdownTimeout()Server shutdown timeout in milliseconds. Defaults to 30000.- Returns:
- Server shutdown timeout.
-
getThreadPoolIdleTimeout
public int getThreadPoolIdleTimeout()Thread pool idle timeout in milliseconds. Defaults to 60000.Threads that are idle for longer than this period may be stopped.
- Returns:
- Thread pool idle timeout.
-
getThreadPoolMaxThreads
public int getThreadPoolMaxThreads()Thread pool maximum threads. Defaults to 200.- Returns:
- Thread pool maximum threads.
-
getThreadPoolMinThreads
public int getThreadPoolMinThreads()Thread pool minimum threads. Defaults to 8.- Returns:
- Thread pool minimum threads.
-
getThreadPoolStopTimeout
public long getThreadPoolStopTimeout()Thread pool stop timeout in milliseconds. Defaults to 5000.The maximum time allowed for the service to shut down.
- Returns:
- Thread pool stop timeout.
-
getThreadPoolThreadsPriority
public int getThreadPoolThreadsPriority()Thread pool threads priority. Defaults toThread.NORM_PRIORITY.- Returns:
- Thread pool maximum threads.
-
getWrappedServer
protected org.eclipse.jetty.server.Server getWrappedServer()Returns the wrapped Jetty server.- Returns:
- The wrapped Jetty server.
-
setWrappedServer
protected void setWrappedServer(org.eclipse.jetty.server.Server wrappedServer) Sets the wrapped Jetty server.- Parameters:
wrappedServer- The wrapped Jetty server.
-
start
Description copied from class:RestletHelperStart callback.- Overrides:
startin classConnectorHelper<Server>- Throws:
Exception
-
stop
Description copied from class:RestletHelperStop callback.- Overrides:
stopin classServerHelper- Throws:
Exception
-