## org.eclipse.jetty.io.nio
Class SelectorManager

    java.lang.Object
      org.eclipse.jetty.util.component.AbstractLifeCycle
          org.eclipse.jetty.io.nio.SelectorManager

All Implemented Interfaces:
  LifeCycle

    public abstract class SelectorManager

extends AbstractLifeCycle

The Selector Manager manages and number of SelectSets to allow NIO scheduling to scale to large numbers of connections.

This class works around a number of know JVM bugs. For details see http://wiki.eclipse.org/Jetty/Feature/JVM_NIO_Bug

Nested Class Summary
`class` `SelectorManager.SelectSet`

Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
`AbstractLifeCycle.AbstractLifeCycleListener`

Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
`LifeCycle.Listener`

Field Summary

Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
`_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

Constructor Summary
`SelectorManager()`

Method Summary
`abstract boolean` `dispatch(java.lang.Runnable task)`
`void` `doSelect(int acceptorID)`
`protected void` `doStart()`
`protected void` `doStop()`
`void` `dump()`
`protected abstract void` `endPointClosed(SelectChannelEndPoint endpoint)`
`protected abstract void` `endPointOpened(SelectChannelEndPoint endpoint)`
`protected abstract void` `endPointUpgraded(ConnectedEndPoint endpoint, Connection oldConnection)`
`long` `getLowResourcesConnections()`
`long` `getLowResourcesMaxIdleTime()`
`long` `getMaxIdleTime()`
`SelectorManager.SelectSet` `getSelectSet(int i)`
`int` `getSelectSets()`
`protected abstract Connection` `newConnection(java.nio.channels.SocketChannel channel, SelectChannelEndPoint endpoint)`
`protected abstract SelectChannelEndPoint` `newEndPoint(java.nio.channels.SocketChannel channel, SelectorManager.SelectSet selectSet, java.nio.channels.SelectionKey sKey)` Create a new end point
`void` `register(java.nio.channels.ServerSocketChannel acceptChannel)` Register a `ServerSocketChannel`
`void` `register(java.nio.channels.SocketChannel channel)` Register a channel
`void` `register(java.nio.channels.SocketChannel channel, java.lang.Object att)` Register a channel
`void` `setLowResourcesConnections(long lowResourcesConnections)` Set the number of connections, which if exceeded places this manager in low resources state.
`void` `setLowResourcesMaxIdleTime(long lowResourcesMaxIdleTime)`
`void` `setMaxIdleTime(long maxIdleTime)`
`void` `setSelectSets(int selectSets)`

Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
`addLifeCycleListener, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SelectorManager

    public SelectorManager()

Method Detail

### setMaxIdleTime

    public void setMaxIdleTime(long maxIdleTime)

  Parameters:
    `maxIdleTime` - The maximum period in milli seconds that a connection may be idle before it is closed.
  See Also:
    `setLowResourcesMaxIdleTime(long)`

### setSelectSets

    public void setSelectSets(int selectSets)

  Parameters:
    `selectSets` - number of select sets to create

### getMaxIdleTime

    public long getMaxIdleTime()

  Returns:
    the max idle time

### getSelectSets

    public int getSelectSets()

  Returns:
    the number of select sets in use

### getSelectSet

    public SelectorManager.SelectSet getSelectSet(int i)

  Parameters:
    `i` -
  Returns:
    The select set

### register

    public void register(java.nio.channels.SocketChannel channel,
                         java.lang.Object att)

  Register a channel

  Parameters:
    `channel` -
    `att` - Attached Object

### register

    public void register(java.nio.channels.SocketChannel channel)

  Register a channel

  Parameters:
    `channel` -
    `att` - Attached Object

### register

    public void register(java.nio.channels.ServerSocketChannel acceptChannel)

  Register a `ServerSocketChannel`

  Parameters:
    `acceptChannel` -

### getLowResourcesConnections

    public long getLowResourcesConnections()

  Returns:
    the lowResourcesConnections

### setLowResourcesConnections

    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.

  Parameters:
    `lowResourcesConnections` - the number of connections
  See Also:
    `setLowResourcesMaxIdleTime(long)`

### getLowResourcesMaxIdleTime

    public long getLowResourcesMaxIdleTime()

  Returns:
    the lowResourcesMaxIdleTime

### setLowResourcesMaxIdleTime

    public void setLowResourcesMaxIdleTime(long lowResourcesMaxIdleTime)

  Parameters:
    `lowResourcesMaxIdleTime` - the period in ms that a connection is allowed to be idle when this SelectSet has more connections than `getLowResourcesConnections()`
  See Also:
    `setMaxIdleTime(long)`

### doSelect

    public void doSelect(int acceptorID)
                  throws java.io.IOException

  Parameters:
    `acceptorID` -
  Throws:
    `java.io.IOException`

### dispatch

    public abstract boolean dispatch(java.lang.Runnable task)

### doStart

    protected void doStart()
                    throws java.lang.Exception

  Overrides:
    `doStart` in class `AbstractLifeCycle`
  Throws:
    `java.lang.Exception`

### doStop

    protected void doStop()
                   throws java.lang.Exception

  Overrides:
    `doStop` in class `AbstractLifeCycle`
  Throws:
    `java.lang.Exception`

### endPointClosed

    protected abstract void endPointClosed(SelectChannelEndPoint endpoint)

  Parameters:
    `endpoint` -

### endPointOpened

    protected abstract void endPointOpened(SelectChannelEndPoint endpoint)

  Parameters:
    `endpoint` -

### endPointUpgraded

    protected abstract void endPointUpgraded(ConnectedEndPoint endpoint,
                                             Connection oldConnection)

### newConnection

    protected abstract Connection newConnection(java.nio.channels.SocketChannel channel,
                                                SelectChannelEndPoint endpoint)

### newEndPoint

    protected abstract SelectChannelEndPoint newEndPoint(java.nio.channels.SocketChannel channel,
                                                         SelectorManager.SelectSet selectSet,
                                                         java.nio.channels.SelectionKey sKey)
                                                  throws java.io.IOException

  Create a new end point

  Parameters:
    `channel` -
    `selectSet` -
    `sKey` - the selection key
  Returns:
    the new endpoint `SelectChannelEndPoint`
  Throws:
    `java.io.IOException`

### dump

    public void dump()

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.