public class SelectChannelConnector extends AbstractNIOConnector
This connector uses efficient NIO buffers with a non blocking threading model. Direct NIO buffers are used and threads are only allocated to connections with requests. Synchronization is used to simulate blocking for the servlet API, and any unflushed content at the end of request handling is written asynchronously.
This connector is best used when there are a many connections that have idle periods.
When used with Continuation, threadless waits are supported.
If a filter or servlet returns after calling Continuation.suspend() or when a
runtime exception is thrown from a call to Continuation.undispatch(), Jetty will
will not send a response to the client. Instead the thread is released and the Continuation is
placed on the timer queue. If the Continuation timeout expires, or it's
resume method is called, then the request is again allocated a thread and the request is retried.
The limitation of this approach is that request content is not available on the retried request,
thus if possible it should be read after the continuation or saved as a request attribute or as the
associated object of the Continuation instance.
AbstractLifeCycle.AbstractLifeCycleListenerLifeCycle.Listener| Modifier and Type | Field and Description |
|---|---|
protected ServerSocketChannel |
_acceptChannel |
_buffers, _lowResourceMaxIdleTime, _maxIdleTime, _soLingerTime_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING| Constructor and Description |
|---|
SelectChannelConnector()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(int acceptorID) |
void |
close() |
void |
customize(EndPoint endpoint,
Request request)
Customize a request for an endpoint.
|
protected void |
doStart() |
protected void |
endPointClosed(SelectChannelEndPoint endpoint) |
Object |
getConnection() |
int |
getLocalPort() |
int |
getLowResourcesConnections() |
int |
getLowResourcesMaxIdleTime() |
SelectorManager |
getSelectorManager() |
protected AsyncConnection |
newConnection(SocketChannel channel,
AsyncEndPoint endpoint) |
protected SelectChannelEndPoint |
newEndPoint(SocketChannel channel,
SelectorManager.SelectSet selectSet,
SelectionKey key) |
void |
open()
Opens the connector
|
void |
persist(EndPoint endpoint)
Persist an endpoint.
|
void |
setLowResourcesConnections(int lowResourcesConnections)
Set the number of connections, which if exceeded places this manager in low resources state.
|
void |
setLowResourcesMaxIdleTime(int lowResourcesMaxIdleTime)
Set the period in ms that a connection is allowed to be idle when this there are more
than
getLowResourcesConnections() connections. |
void |
setMaxIdleTime(int maxIdleTime)
Set the maximum Idle time for a connection, which roughly translates to the
Socket.setSoTimeout(int) call, although with NIO implementations
other mechanisms may be used to implement the timeout. |
void |
setThreadPool(ThreadPool pool)
Set the ThreadPool.
|
getUseDirectBuffers, setUseDirectBufferscheckForwardedHeaders, configure, connectionClosed, connectionOpened, connectionUpgraded, doStop, getAcceptorPriorityOffset, getAcceptors, getAcceptQueueSize, getConfidentialPort, getConfidentialScheme, getConnections, getConnectionsDurationMax, getConnectionsDurationMean, getConnectionsDurationStdDev, getConnectionsDurationTotal, getConnectionsOpen, getConnectionsOpenMax, getConnectionsRequestsMax, getConnectionsRequestsMean, getConnectionsRequestsStdDev, getForwardedCipherSuiteHeader, getForwardedForHeader, getForwardedHostHeader, getForwardedProtoHeader, getForwardedServerHeader, getForwardedSslSessionIdHeader, getHost, getHostHeader, getIntegralPort, getIntegralScheme, getLeftMostFieldValue, getLowResourceMaxIdleTime, getMaxBuffers, getMaxIdleTime, getName, getPort, getRequestBuffers, getRequestBufferSize, getRequestBufferType, getRequestHeaderSize, getRequestHeaderType, getRequests, getResolveNames, getResponseBuffers, getResponseBufferSize, getResponseBufferType, getResponseHeaderSize, getResponseHeaderType, getReuseAddress, getServer, getSoLingerTime, getStatsOn, getStatsOnMs, getThreadPool, isConfidential, isForwarded, isIntegral, isLowResources, join, setAcceptorPriorityOffset, setAcceptors, setAcceptQueueSize, setConfidentialPort, setConfidentialScheme, setForwarded, setForwardedCipherSuiteHeader, setForwardedForHeader, setForwardedHostHeader, setForwardedProtoHeader, setForwardedServerHeader, setForwardedSslSessionIdHeader, setHost, setHostHeader, setIntegralPort, setIntegralScheme, setLowResourceMaxIdleTime, setMaxBuffers, setName, setPort, setRequestBuffers, setRequestBufferSize, setRequestHeaderSize, setResolveNames, setResponseBuffers, setResponseBufferSize, setResponseHeaderSize, setReuseAddress, setServer, setSoLingerTime, setStatsOn, statsReset, stopAccept, toStringaddBean, addBean, contains, destroy, dump, dump, dump, dump, dump, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanageaddLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopprotected ServerSocketChannel _acceptChannel
public void setThreadPool(ThreadPool pool)
AbstractConnectorAggregateLifeCycle.addBean(Object) so that
it's lifecycle may be managed as a AggregateLifeCycle.setThreadPool in class AbstractConnectorpool - the threadPool to setpublic void accept(int acceptorID)
throws IOException
accept in class AbstractConnectorIOExceptionpublic void close()
throws IOException
IOExceptionpublic void customize(EndPoint endpoint, Request request) throws IOException
Connectorcustomize in interface Connectorcustomize in class AbstractConnectorIOExceptionpublic void persist(EndPoint endpoint) throws IOException
Connectorpersist in interface Connectorpersist in class AbstractConnectorIOExceptionpublic SelectorManager getSelectorManager()
public Object getConnection()
public int getLocalPort()
public void open()
throws IOException
ConnectorIOExceptionpublic void setMaxIdleTime(int maxIdleTime)
AbstractConnectorSocket.setSoTimeout(int) call, although with NIO implementations
other mechanisms may be used to implement the timeout. The max idle time is applied:
Previously, Jetty supported separate idle timeouts and IO operation timeouts, however the expense of changing the value of soTimeout was significant, so these timeouts were merged. With the advent of NIO, it may be possible to again differentiate these values (if there is demand).
setMaxIdleTime in interface ConnectorsetMaxIdleTime in class AbstractConnectormaxIdleTime - The maxIdleTime to set.public int getLowResourcesConnections()
public void setLowResourcesConnections(int lowResourcesConnections)
lowResourcesConnections - the number of connectionssetLowResourcesMaxIdleTime(int)public int getLowResourcesMaxIdleTime()
getLowResourcesMaxIdleTime in class AbstractConnectorpublic void setLowResourcesMaxIdleTime(int lowResourcesMaxIdleTime)
getLowResourcesConnections() connections. This allows the server to rapidly close idle connections
in order to gracefully handle high load situations.setLowResourcesMaxIdleTime in class AbstractConnectorlowResourcesMaxIdleTime - the period in ms that a connection is allowed to be idle when resources are low.setMaxIdleTime(int)protected void doStart()
throws Exception
doStart in class AbstractConnectorExceptionprotected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key) throws IOException
IOExceptionprotected void endPointClosed(SelectChannelEndPoint endpoint)
protected AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint)
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.