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 org.mortbay.util.ajax.Continuation, threadless waits are supported. When
a filter or servlet calls getEvent on a Continuation, a org.mortbay.jetty.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.
| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| protected transient ServerSocketChannel | |
| private long | |
| private long | |
| private SelectorManager |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | customize(EndPoint endpoint, Request request)
Overrides org. Implements org. |
| protected void | |
| protected void | |
| public Object | |
| public boolean | Returns: Returns the assumeShortDispatch.Get delay select key update If true, the select set is not updated when a endpoint is dispatched for reading. |
| public int | |
| public long | |
| public long | |
| protected Connection | |
| public Continuation | |
| protected SelectChannelEndPoint | |
| public void | |
| public void | persist(EndPoint endpoint)
Overrides org. Implements org. |
| public void | setDelaySelectKeyUpdate(boolean
If true, updating a delay)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 | setLowResourceMaxIdleTime(int
the period in ms that a connection is allowed to be idle when resources are low. lowResourcesMaxIdleTime)Overrides org. Implements org. getLowResourcesConnections() connections.
|
| public void | setLowResourcesConnections(long
the number of connections lowResourcesConnections)Set the number of connections, which if exceeded places this manager in low resources state. |
| public void | setLowResourcesMaxIdleTime(long
the period in ms that a connection is allowed to be idle when resources are low. lowResourcesMaxIdleTime)
Deprecated
use
Set the period in ms that a connection is allowed to be idle when this there are more
than setLowResourceMaxIdleTime(int)
getLowResourcesConnections() connections.
|
| public void | setMaxIdleTime(int
The maxIdleTime to set. maxIdleTime)Overrides org. Implements org. Socket#setSoTimeout(int) call, although with NIO
implementations other mechanisms may be used to implement the timeout.
|
| _acceptChannel | back to summary |
|---|---|
| protected transient ServerSocketChannel _acceptChannel | |
| _lowResourcesConnections | back to summary |
|---|---|
| private long _lowResourcesConnections | |
| _lowResourcesMaxIdleTime | back to summary |
|---|---|
| private long _lowResourcesMaxIdleTime | |
| _manager | back to summary |
|---|---|
| private SelectorManager _manager | |
| SelectChannelConnector | back to summary |
|---|---|
| public SelectChannelConnector() Constructor. | |
| accept | back to summary |
|---|---|
| public void accept(int acceptorID) throws IOException Implements abstract org. | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements org. | |
| customize | back to summary |
|---|---|
| public void customize(EndPoint endpoint, Request request) throws IOException Overrides org. Implements org. Doc from org. Customize a request for an endpoint. Called on every request to allow customization of the request for the particular endpoint (eg security properties from a SSL connection). | |
| doStart | back to summary |
|---|---|
| protected void doStart() throws Exception Overrides org. | |
| doStop | back to summary |
|---|---|
| protected void doStop() throws Exception Overrides org. | |
| getConnection | back to summary |
|---|---|
| public Object getConnection() Implements org.
| |
| getDelaySelectKeyUpdate | back to summary |
|---|---|
| public boolean getDelaySelectKeyUpdate() Get delay select key update If true, the select set is not updated when a endpoint is dispatched for reading. The assumption is that the task will be short and thus will probably be complete before the select is tried again.
| |
| getLocalPort | back to summary |
|---|---|
| public int getLocalPort() Implements org.
| |
| getLowResourcesConnections | back to summary |
|---|---|
public long getLowResourcesConnections()
| |
| getLowResourcesMaxIdleTime | back to summary |
|---|---|
public long getLowResourcesMaxIdleTime()
| |
| newConnection | back to summary |
|---|---|
| protected Connection newConnection(SocketChannel channel, SelectChannelEndPoint endpoint) | |
| newContinuation | back to summary |
|---|---|
| public Continuation newContinuation() Overrides org. Implements org. | |
| newEndPoint | back to summary |
|---|---|
| protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectorManager. | |
| open | back to summary |
|---|---|
| public void open() throws IOException Implements org. Doc from org. Opens the connector | |
| persist | back to summary |
|---|---|
| public void persist(EndPoint endpoint) throws IOException Overrides org. Implements org. Doc from org. Persist an endpoint. Called after every request if the connection is to remain open. | |
| setDelaySelectKeyUpdate | back to summary |
|---|---|
public void setDelaySelectKeyUpdate(boolean delay)
| |
| setLowResourceMaxIdleTime | back to summary |
|---|---|
| public void setLowResourceMaxIdleTime(int lowResourcesMaxIdleTime) Overrides org. Implements org. Set the period in ms that a connection is allowed to be idle when this there are more
than
| |
| setLowResourcesConnections | back to summary |
|---|---|
| public void setLowResourcesConnections(long lowResourcesConnections) Set the number of connections, which if exceeded places this manager in low resources state. This is not an exact measure as the connection count is averaged over the select sets.
| |
| setLowResourcesMaxIdleTime | back to summary |
|---|---|
| public void setLowResourcesMaxIdleTime(long lowResourcesMaxIdleTime)
Deprecated Set the period in ms that a connection is allowed to be idle when this there are more
than
| |
| setMaxIdleTime | back to summary |
|---|---|
| public void setMaxIdleTime(int maxIdleTime) Overrides org. Implements org. Doc from org. Set the maximum Idle time for a connection, which roughly translates
to the
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).
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides org. Implements org. |
| public void | undispatch()
Overrides org. |
| ConnectorEndPoint | back to summary |
|---|---|
| public ConnectorEndPoint(SocketChannel channel, SelectorManager. | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides org. Implements org. Doc from org. Close any backing stream associated with the buffer | |
| undispatch | back to summary |
|---|---|
| public void undispatch() Overrides org. Doc from org. Called when a dispatched thread is no longer handling the endpoint. The selection key operations are updated. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv SelectChannelEndPoint | |
| pack-priv boolean | |
| pack-priv Object | |
| pack-priv boolean | |
| pack-priv boolean | |
| pack-priv boolean | |
| pack-priv RetryRequest | |
| pack-priv long |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public Object | getObject()
Implements org. |
| public long | |
| public boolean | |
| public boolean | |
| public boolean | |
| public void | |
| public void | |
| public void | |
| public void | setObject(Object
An arbitrary object to associate with the continuation object)Implements org. |
| public boolean | suspend(long
A timeout of < 0 will cause an immediate return. I timeout of 0 will wait indefinitely. timeout)Implements org. |
| public String | |
| public boolean |
| _endPoint | back to summary |
|---|---|
| pack-priv SelectChannelEndPoint _endPoint | |
| _new | back to summary |
|---|---|
| pack-priv boolean _new | |
| _object | back to summary |
|---|---|
| pack-priv Object _object | |
| _parked | back to summary |
|---|---|
| pack-priv boolean _parked | |
| _pending | back to summary |
|---|---|
| pack-priv boolean _pending | |
| _resumed | back to summary |
|---|---|
| pack-priv boolean _resumed | |
| _retry | back to summary |
|---|---|
| pack-priv RetryRequest _retry | |
| _timeout | back to summary |
|---|---|
| pack-priv long _timeout | |
| RetryContinuation | back to summary |
|---|---|
| public RetryContinuation() | |
| expire | back to summary |
|---|---|
| public void expire() Overrides org. Doc from org. Expire task.
This method is called when the timeout expires. It is called
in the scope of the synchronize block (on this) that sets
the | |
| getObject | back to summary |
|---|---|
| public Object getObject() Implements org. Doc from org. Arbitrary object associated with the continuation for context.
| |
| getTimeout | back to summary |
|---|---|
| public long getTimeout() | |
| isNew | back to summary |
|---|---|
| public boolean isNew() Implements org. Doc from org. Is this a newly created Continuation.
A newly created continuation has not had
| |
| isPending | back to summary |
|---|---|
| public boolean isPending() Implements org. Doc from org. Get the pending status?
A continuation is pending while the handling of a call to suspend has not completed.
For blocking continuations, pending is true only during the call to
| |
| isResumed | back to summary |
|---|---|
| public boolean isResumed() Implements org. Doc from org. Get the resumed status?
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Doc from org. Reset the continuation. Cancel any pending status of the continuation. | |
| resume | back to summary |
|---|---|
| public void resume() Implements org. Doc from org. Resume the request. Resume a suspended request. The passed event will be returned in the getObject method. | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation. | |
| setObject | back to summary |
|---|---|
| public void setObject(Object object) Implements org. Doc from org. Arbitrary object associated with the continuation for context.
| |
| suspend | back to summary |
|---|---|
| public boolean suspend(long timeout) Implements org. Doc from org. Suspend handling. This method will suspend the request for the timeout or until resume is called.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
| |
| undispatch | back to summary |
|---|---|
| public boolean undispatch() | |