Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.jetty.nio
Class SelectChannelConnector

    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

All Implemented Interfaces:
  LifeCycle, Buffers, Connector, NIOConnector

Direct Known Subclasses:
  SslSelectChannelConnector

    public class SelectChannelConnector

extends AbstractNIOConnector

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.

Author:
  gregw

Nested Class Summary
`static class` | `SelectChannelConnector.ConnectorEndPoint`
`static class` | `SelectChannelConnector.RetryContinuation`

Field Summary

Fields inherited from class org.mortbay.jetty.AbstractConnector
`_lowResourceMaxIdleTime, _maxIdleTime, _soLingerTime`

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()`
`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` | `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.AbstractConnector
`configure, connectionClosed, connectionOpened, getAcceptors, getAcceptQueueSize, getConfidentialPort, getConfidentialScheme, getConnections, getConnectionsDurationAve, getConnectionsDurationMax, getConnectionsDurationMin, getConnectionsDurationTotal, getConnectionsOpen, getConnectionsOpenMax, getConnectionsOpenMin, getConnectionsRequestsAve, getConnectionsRequestsMax, getConnectionsRequestsMin, getHost, getIntegralPort, getIntegralScheme, getLowResourceMaxIdleTime, getMaxIdleTime, getName, getPort, getRequests, getResolveNames, getServer, getSoLingerTime, getStatsOn, getStatsOnMs, getThreadPool, isConfidential, isIntegral, join, setAcceptors, setAcceptQueueSize, setConfidentialPort, setConfidentialScheme, setHost, setIntegralPort, setIntegralScheme, setLowResourceMaxIdleTime, setName, setPort, setResolveNames, setServer, setSoLingerTime, setStatsOn, setThreadPool, statsReset, toString`

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

### SelectChannelConnector

    public SelectChannelConnector()

  Constructor.

Method Detail

### accept

    public void accept(int acceptorID)
                throws IOException

  Specified by:
    `accept` in class `AbstractConnector`
  Throws:
    `IOException`

### stopAccept

    public void stopAccept(int acceptorID)
                    throws Exception

  Overrides:
    `stopAccept` in class `AbstractConnector`
  Throws:
    `Exception`

### close

    public void close()
               throws IOException

  Throws:
    `IOException`

### customize

    public void customize(EndPoint endpoint,
                          Request request)
                   throws IOException

  Description copied from interface: `Connector`
  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).

  Specified by:
    `customize` in interface `Connector`
  Overrides:
    `customize` in class `AbstractConnector`
  Throws:
    `IOException`

### persist

    public void persist(EndPoint endpoint)
                 throws IOException

  Description copied from interface: `Connector`
  Persist an endpoint. Called after every request if the connection is to remain open.

  Specified by:
    `persist` in interface `Connector`
  Overrides:
    `persist` in class `AbstractConnector`
  Throws:
    `IOException`

### getConnection

    public Object getConnection()

  Returns:
    the underlying socket, channel, buffer etc. for the connector.

### getDelaySelectKeyUpdate

    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.

  Returns:
    Returns the assumeShortDispatch.

### getLocalPort

    public int getLocalPort()

  Returns:
    The actual port the connector is listening on or -1 if there is no port or the connector is not open.

### newContinuation

    public Continuation newContinuation()

  Specified by:
    `newContinuation` in interface `Connector`
  Overrides:
    `newContinuation` in class `AbstractConnector`

### open

    public void open()
              throws IOException

  Description copied from interface: `Connector`
  Opens the connector

  Specified by:
    `open` in interface `Connector`
  Specified by:
    `open` in class `AbstractConnector`
  Throws:
    `IOException`

### setDelaySelectKeyUpdate

    public void setDelaySelectKeyUpdate(boolean delay)

  Parameters:
    `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.

### setMaxIdleTime

    public void setMaxIdleTime(int maxIdleTime)

  Specified by:
    `setMaxIdleTime` in interface `Connector`
  Overrides:
    `setMaxIdleTime` in class `AbstractConnector`
  Parameters:
    `maxIdleTime` - The maxIdleTime to set.

### doStart

    protected void doStart()
                    throws Exception

  Overrides:
    `doStart` in class `AbstractConnector`
  Throws:
    `Exception`

### doStop

    protected void doStop()
                   throws Exception

  Overrides:
    `doStop` in class `AbstractConnector`
  Throws:
    `Exception`

### newEndPoint

    protected SelectChannelEndPoint newEndPoint(SocketChannel channel,
                                                SelectorManager.SelectSet selectSet,
                                                SelectionKey key)
                                         throws IOException

  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2007 Mort Bay Consulting. All Rights Reserved.