Class JettyServerHelper
- java.lang.Object
-
- org.restlet.engine.Helper
-
- org.restlet.engine.RestletHelper<T>
-
- org.restlet.engine.connector.ConnectorHelper<Server>
-
- org.restlet.engine.connector.ServerHelper
-
- org.restlet.engine.adapter.HttpServerHelper
-
- org.restlet.ext.jetty.JettyServerHelper
-
- Direct Known Subclasses:
HttpServerHelper,HttpsServerHelper
public abstract class JettyServerHelper extends HttpServerHelper
Abstract Jetty web server connector. Here is the list of parameters that are supported. They should be set in the Server's context before it is started: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_PRIORITYThread 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 Runtime.availableProcessors()/ 2, with a minimum of 1connector.selectors int -1 Connector selector thread count; when -1, Jetty will default to Runtime.availableProcessors()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 resetconnector.soLingerTime int -1 Connector TCP/IP SO linger time in milliseconds; when -1 is disabled; see Socket.setSoLinger(boolean, int)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.maxConnections int 0 Low resource monitor max connections; when 0, the check is disabled lowResource.idleTimeout int 1000 Low resource monitor idle timeout in milliseconds; applied to EndPoints when in the low resources state lowResource.stopTimeout long 30000 Low resource monitor stop timeout in milliseconds; the maximum time allowed for the service to shutdown
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classJettyServerHelper.WrappedServerJetty server wrapped by a parent Restlet HTTP server connector.
-
Field Summary
Fields Modifier and Type Field Description private org.eclipse.jetty.server.ServerwrappedServerThe wrapped Jetty server.
-
Constructor Summary
Constructors Constructor Description JettyServerHelper(Server server)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private org.eclipse.jetty.server.HttpConfigurationcreateConfiguration()Creates a Jetty HTTP configuration.protected abstract org.eclipse.jetty.server.ConnectionFactory[]createConnectionFactories(org.eclipse.jetty.server.HttpConfiguration configuration)Creates new internal Jetty connection factories.private org.eclipse.jetty.server.ConnectorcreateConnector(org.eclipse.jetty.server.Server server)Creates a Jetty connector.private org.eclipse.jetty.server.LowResourceMonitorcreateLowResourceMonitor(org.eclipse.jetty.server.Server server)Creates a Jetty low resource monitor.private org.eclipse.jetty.server.ServercreateServer()Creates a Jetty server.private org.eclipse.jetty.util.thread.ThreadPoolcreateThreadPool()Creates a Jetty thread pool.intgetConnectorAcceptors()Connector acceptor thread count.intgetConnectorAcceptQueueSize()Connector accept queue size.org.eclipse.jetty.io.ByteBufferPoolgetConnectorByteBufferPool()Connector byte buffer pool.java.util.concurrent.ExecutorgetConnectorExecutor()Connector executor.intgetConnectorIdleTimeout()Connector idle timeout in milliseconds.org.eclipse.jetty.util.thread.SchedulergetConnectorScheduler()Connector scheduler.intgetConnectorSelectors()Connector selector thread count.intgetConnectorSoLingerTime()Connector TCP/IP SO linger time in milliseconds.intgetConnectorStopTimeout()Connector stop timeout in milliseconds.intgetHttpHeaderCacheSize()HTTP header cache size in bytes.intgetHttpOutputBufferSize()HTTP output buffer size in bytes.intgetHttpRequestHeaderSize()HTTP request header size in bytes.intgetHttpResponseHeaderSize()HTTP response header size in bytes.intgetLowResourceMonitorIdleTimeout()Low resource monitor idle timeout in milliseconds.intgetLowResourceMonitorMaxConnections()Low resource monitor max connections.longgetLowResourceMonitorMaxMemory()Low resource monitor max memory in bytes.intgetLowResourceMonitorPeriod()Low resource monitor period in milliseconds.longgetLowResourceMonitorStopTimeout()Low resource monitor stop timeout in milliseconds.booleangetLowResourceMonitorThreads()Low resource monitor, whether to check if we're low on threads.intgetThreadPoolIdleTimeout()Thread pool idle timeout in milliseconds.intgetThreadPoolMaxThreads()Thread pool maximum threads.intgetThreadPoolMinThreads()Thread pool minimum threads.longgetThreadPoolStopTimeout()Thread pool stop timeout in milliseconds.intgetThreadPoolThreadsPriority()Thread pool threads priority.protected org.eclipse.jetty.server.ServergetWrappedServer()Returns 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, setAdapter
-
Methods inherited from class org.restlet.engine.connector.ServerHelper
handle, setEphemeralPort, setEphemeralPort
-
Methods inherited from class org.restlet.engine.connector.ConnectorHelper
getConnectorService, getContext, getProtocols, update
-
Methods inherited from class org.restlet.engine.RestletHelper
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, setHelped
-
-
-
-
Constructor Detail
-
JettyServerHelper
public JettyServerHelper(Server server)
Constructor.- Parameters:
server- The server to help.
-
-
Method Detail
-
createConfiguration
private org.eclipse.jetty.server.HttpConfiguration createConfiguration()
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.
-
createConnector
private org.eclipse.jetty.server.Connector createConnector(org.eclipse.jetty.server.Server server)
Creates a Jetty connector.- Parameters:
server- The Jetty server.- Returns:
- A Jetty connector.
-
createLowResourceMonitor
private org.eclipse.jetty.server.LowResourceMonitor createLowResourceMonitor(org.eclipse.jetty.server.Server server)
Creates a Jetty low resource monitor.- Parameters:
server- A Jetty server.- Returns:
- A Jetty low resource monitor or null.
-
createServer
private org.eclipse.jetty.server.Server createServer()
Creates a Jetty server.- Returns:
- A Jetty server.
-
createThreadPool
private org.eclipse.jetty.util.thread.ThreadPool createThreadPool()
Creates a Jetty thread pool.- Returns:
- A Jetty thread pool.
-
getConnectorAcceptors
public int getConnectorAcceptors()
Connector acceptor thread count. Defaults to -1. When -1, Jetty will default toRuntime.availableProcessors()/ 2, with a minimum of 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
public java.util.concurrent.Executor 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.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.
- 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 0, Jetty will default toRuntime.availableProcessors().- Returns:
- Connector acceptor thread count.
-
getConnectorSoLingerTime
public int getConnectorSoLingerTime()
Connector TCP/IP SO linger time in milliseconds. Defaults to -1 (disabled).See
Socket.setSoLinger(boolean, int).- Returns:
- Connector TCP/IP SO linger time.
-
getConnectorStopTimeout
public int getConnectorStopTimeout()
Connector stop timeout in milliseconds. Defaults to 30000.The maximum time allowed for the service to shutdown.
- Returns:
- Connector stop timeout.
-
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.
-
getLowResourceMonitorMaxConnections
public int getLowResourceMonitorMaxConnections()
Low resource monitor max connections. Defaults to 0. When 0, the check is disabled.- Returns:
- Low resource monitor max connections.
-
getLowResourceMonitorMaxMemory
public long getLowResourceMonitorMaxMemory()
Low resource monitor max memory in bytes. Defaults to 0. When 0, the check 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.
-
getLowResourceMonitorStopTimeout
public long getLowResourceMonitorStopTimeout()
Low resource monitor stop timeout in milliseconds. Defaults to 30000.The maximum time allowed for the service to shutdown.
- Returns:
- Low resource monitor stop timeout.
-
getLowResourceMonitorThreads
public boolean getLowResourceMonitorThreads()
Low resource monitor, whether to check if we're low on threads. Defaults to true.- Returns:
- Low resource monitor threads.
-
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 shutdown.
- 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
public void start() throws java.lang.ExceptionDescription copied from class:RestletHelperStart callback.- Overrides:
startin classConnectorHelper<Server>- Throws:
java.lang.Exception
-
stop
public void stop() throws java.lang.ExceptionDescription copied from class:RestletHelperStop callback.- Overrides:
stopin classServerHelper- Throws:
java.lang.Exception
-
-