Class JettyServerHelper
- java.lang.Object
-
- org.restlet.engine.Helper
-
- org.restlet.engine.RestletHelper<T>
-
- org.restlet.engine.connector.ConnectorHelper<org.restlet.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 org.restlet.engine.adapter.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:list of supported parameters 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 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 - Author:
- Jerome Louvel, Tal Liron
- See Also:
- Jetty home page, Jetty SPDY page, Jetty NPN configuration page
-
-
Constructor Summary
Constructors Constructor Description JettyServerHelper(org.restlet.Server server)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract org.eclipse.jetty.server.ConnectionFactory[]
createConnectionFactories(org.eclipse.jetty.server.HttpConfiguration configuration)
Creates new internal Jetty connection factories.int
getConnectorAcceptors()
Connector acceptor thread count.int
getConnectorAcceptQueueSize()
Connector accept queue size.org.eclipse.jetty.io.ByteBufferPool
getConnectorByteBufferPool()
Connector byte buffer pool.java.util.concurrent.Executor
getConnectorExecutor()
Connector executor.int
getConnectorIdleTimeout()
Connector idle timeout in milliseconds.org.eclipse.jetty.util.thread.Scheduler
getConnectorScheduler()
Connector scheduler.int
getConnectorSelectors()
Connector selector thread count.int
getConnectorSoLingerTime()
Connector TCP/IP SO linger time in milliseconds.int
getConnectorStopTimeout()
Connector stop timeout in milliseconds.int
getHttpHeaderCacheSize()
HTTP header cache size in bytes.int
getHttpOutputBufferSize()
HTTP output buffer size in bytes.int
getHttpRequestHeaderSize()
HTTP request header size in bytes.int
getHttpResponseHeaderSize()
HTTP response header size in bytes.int
getLowResourceMonitorIdleTimeout()
Low resource monitor idle timeout in milliseconds.int
getLowResourceMonitorMaxConnections()
Low resource monitor max connections.long
getLowResourceMonitorMaxMemory()
Low resource monitor max memory in bytes.int
getLowResourceMonitorPeriod()
Low resource monitor period in milliseconds.long
getLowResourceMonitorStopTimeout()
Low resource monitor stop timeout in milliseconds.boolean
getLowResourceMonitorThreads()
Low resource monitor, whether to check if we're low on threads.int
getThreadPoolIdleTimeout()
Thread pool idle timeout in milliseconds.int
getThreadPoolMaxThreads()
Thread pool maximum threads.int
getThreadPoolMinThreads()
Thread pool minimum threads.long
getThreadPoolStopTimeout()
Thread pool stop timeout in milliseconds.int
getThreadPoolThreadsPriority()
Thread pool threads priority.protected org.eclipse.jetty.server.Server
getWrappedServer()
Returns the wrapped Jetty server.protected void
setWrappedServer(org.eclipse.jetty.server.Server wrappedServer)
Sets the wrapped Jetty server.void
start()
void
stop()
-
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
-
-
-
-
Method Detail
-
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.
-
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.Exception
- Overrides:
start
in classorg.restlet.engine.connector.ConnectorHelper<org.restlet.Server>
- Throws:
java.lang.Exception
-
stop
public void stop() throws java.lang.Exception
- Overrides:
stop
in classorg.restlet.engine.connector.ServerHelper
- Throws:
java.lang.Exception
-
-