|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mortbay.component.AbstractLifeCycle org.mortbay.jetty.AbstractBuffers org.mortbay.jetty.AbstractConnector org.mortbay.jetty.nio.AbstractNIOConnector org.mortbay.jetty.nio.SelectChannelConnector
public class SelectChannelConnector
Selecting NIO connector.
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. When
a filter or servlet calls getEvent on a Continuation, a RetryRequest
runtime exception is thrown to allow the thread to exit the current request handling. Jetty will
catch this exception and 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.
Nested Class Summary | |
---|---|
static class |
SelectChannelConnector.ConnectorEndPoint
|
static class |
SelectChannelConnector.RetryContinuation
|
Field Summary |
---|
Fields inherited from class org.mortbay.jetty.AbstractConnector |
---|
_lowResourceMaxIdleTime, _maxIdleTime, _soLingerTime |
Fields inherited from class org.mortbay.jetty.AbstractBuffers |
---|
_loss, BUFFER_LOSS_RATE |
Constructor Summary | |
---|---|
SelectChannelConnector()
Constructor. |
Method Summary | |
---|---|
void |
accept(int acceptorID)
|
void |
close()
|
void |
customize(EndPoint endpoint,
Request request)
Customize a request for an endpoint. |
protected void |
doStart()
|
protected void |
doStop()
|
Object |
getConnection()
|
boolean |
getDelaySelectKeyUpdate()
Get delay select key update If true, the select set is not updated when a endpoint is dispatched for reading. |
int |
getLocalPort()
|
long |
getLowResourcesConnections()
|
long |
getLowResourcesMaxIdleTime()
|
protected Connection |
newConnection(SocketChannel channel,
SelectChannelEndPoint endpoint)
|
Continuation |
newContinuation()
|
protected SelectChannelEndPoint |
newEndPoint(SocketChannel channel,
SelectorManager.SelectSet selectSet,
SelectionKey key)
|
void |
open()
Opens the connector |
void |
persist(EndPoint endpoint)
Persist an endpoint. |
void |
setDelaySelectKeyUpdate(boolean delay)
|
void |
setLowResourceMaxIdleTime(int lowResourcesMaxIdleTime)
Set the period in ms that a connection is allowed to be idle when this there are more than getLowResourcesConnections() connections. |
void |
setLowResourcesConnections(long lowResourcesConnections)
Set the number of connections, which if exceeded places this manager in low resources state. |
void |
setLowResourcesMaxIdleTime(long lowResourcesMaxIdleTime)
Deprecated. use setLowResourceMaxIdleTime(int) |
void |
setMaxIdleTime(int maxIdleTime)
|
void |
stopAccept(int acceptorID)
|
Methods inherited from class org.mortbay.jetty.nio.AbstractNIOConnector |
---|
getUseDirectBuffers, newBuffer, setUseDirectBuffers |
Methods inherited from class org.mortbay.jetty.AbstractBuffers |
---|
getBuffer, getHeaderBufferSize, getRequestBufferSize, getResponseBufferSize, returnBuffer, setHeaderBufferSize, setRequestBufferSize, setResponseBufferSize |
Methods inherited from class org.mortbay.component.AbstractLifeCycle |
---|
isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.mortbay.jetty.Connector |
---|
getHeaderBufferSize, getRequestBufferSize, getResponseBufferSize, setHeaderBufferSize, setRequestBufferSize, setResponseBufferSize |
Methods inherited from interface org.mortbay.component.LifeCycle |
---|
isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, start, stop |
Methods inherited from interface org.mortbay.io.Buffers |
---|
getBuffer, returnBuffer |
Constructor Detail |
---|
public SelectChannelConnector()
Method Detail |
---|
public void accept(int acceptorID) throws IOException
accept
in class AbstractConnector
IOException
public void stopAccept(int acceptorID) throws Exception
stopAccept
in class AbstractConnector
Exception
public void close() throws IOException
IOException
public void customize(EndPoint endpoint, Request request) throws IOException
Connector
customize
in interface Connector
customize
in class AbstractConnector
IOException
public void persist(EndPoint endpoint) throws IOException
Connector
persist
in interface Connector
persist
in class AbstractConnector
IOException
public Object getConnection()
public boolean getDelaySelectKeyUpdate()
public int getLocalPort()
public Continuation newContinuation()
newContinuation
in interface Connector
newContinuation
in class AbstractConnector
public void open() throws IOException
Connector
IOException
public void setDelaySelectKeyUpdate(boolean delay)
delay
- If true, updating a SelectionKey
is delayed until a redundant event is
schedules. This is an optimization that assumes event handling can be completed before the next select
completes.public void setMaxIdleTime(int maxIdleTime)
setMaxIdleTime
in interface Connector
setMaxIdleTime
in class AbstractConnector
maxIdleTime
- The maxIdleTime to set.public long getLowResourcesConnections()
public void setLowResourcesConnections(long lowResourcesConnections)
lowResourcesConnections
- the number of connections#setLowResourcesMaxIdleTime(long)}
public long getLowResourcesMaxIdleTime()
public void setLowResourcesMaxIdleTime(long lowResourcesMaxIdleTime)
setLowResourceMaxIdleTime(int)
getLowResourcesConnections()
connections. This allows the server to rapidly close idle connections
in order to gracefully handle high load situations.
lowResourcesMaxIdleTime
- the period in ms that a connection is allowed to be idle when resources are low.#setMaxIdleTime(long)}
public void setLowResourceMaxIdleTime(int lowResourcesMaxIdleTime)
getLowResourcesConnections()
connections. This allows the server to rapidly close idle connections
in order to gracefully handle high load situations.
setLowResourceMaxIdleTime
in interface Connector
setLowResourceMaxIdleTime
in class AbstractConnector
lowResourcesMaxIdleTime
- the period in ms that a connection is allowed to be idle when resources are low.#setMaxIdleTime(long)}
protected void doStart() throws Exception
doStart
in class AbstractConnector
Exception
protected void doStop() throws Exception
doStop
in class AbstractConnector
Exception
protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key) throws IOException
IOException
protected Connection newConnection(SocketChannel channel, SelectChannelEndPoint endpoint)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |