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.io.nio
Class SelectorManager

    java.lang.Object
      org.mortbay.component.AbstractLifeCycle
          org.mortbay.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.

Author:
  gregw

Nested Class Summary
`class` | `SelectorManager.SelectSet`

Constructor Summary
`SelectorManager()`

Method Summary
`protected abstract SocketChannel` | `acceptChannel(SelectionKey key)`
`protected void` | `connectionFailed(SocketChannel channel, Throwable ex, Object attachment)`
`abstract boolean` | `dispatch(Runnable task)`
`void` | `doSelect(int acceptorID)`
`protected void` | `doStart()`
`protected void` | `doStop()`
`void` | `doStop(int i)`
`protected abstract void` | `endPointClosed(SelectChannelEndPoint endpoint)`
`protected abstract void` | `endPointOpened(SelectChannelEndPoint endpoint)`
`long` | `getLowResourcesConnections()`
`long` | `getLowResourcesMaxIdleTime()`
`long` | `getMaxIdleTime()`
`int` | `getSelectSets()`
`boolean` | `isDelaySelectKeyUpdate()`
`protected abstract Connection` | `newConnection(SocketChannel channel, SelectChannelEndPoint endpoint)`
`protected abstract SelectChannelEndPoint` | `newEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey sKey)`
`void` | `register(ServerSocketChannel acceptChannel)` Register a serverchannel
`void` | `register(SocketChannel channel, Object att)` Register a channel
`void` | `setDelaySelectKeyUpdate(boolean delaySelectKeyUpdate)`
`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.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, 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` -

### getMaxIdleTime

    public long getMaxIdleTime()

  Returns:

### getSelectSets

    public int getSelectSets()

  Returns:

### isDelaySelectKeyUpdate

    public boolean isDelaySelectKeyUpdate()

  Returns:

### register

    public void register(SocketChannel channel,
                         Object att)
                  throws IOException

  Register a channel

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

### register

    public void register(ServerSocketChannel acceptChannel)
                  throws IOException

  Register a serverchannel

  Parameters:
    `acceptChannel` -
  Throws:
    `IOException`

### 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 IOException

  Parameters:
    `acceptorID` -
  Throws:
    `IOException`

### setDelaySelectKeyUpdate

    public void setDelaySelectKeyUpdate(boolean delaySelectKeyUpdate)

  Parameters:
    `delaySelectKeyUpdate` -

### acceptChannel

    protected abstract SocketChannel acceptChannel(SelectionKey key)
                                            throws IOException

  Parameters:
    `key` -
  Returns:
  Throws:
    `IOException`

### dispatch

    public abstract boolean dispatch(Runnable task)
                              throws IOException

  Throws:
    `IOException`

### doStart

    protected void doStart()
                    throws Exception

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

### doStop

    protected void doStop()
                   throws Exception

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

### doStop

    public void doStop(int i)
                throws Exception

  Throws:
    `Exception`

### endPointClosed

    protected abstract void endPointClosed(SelectChannelEndPoint endpoint)

  Parameters:
    `endpoint` -

### endPointOpened

    protected abstract void endPointOpened(SelectChannelEndPoint endpoint)

  Parameters:
    `endpoint` -

### newConnection

    protected abstract Connection newConnection(SocketChannel channel,
                                                SelectChannelEndPoint endpoint)

### newEndPoint

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

  Parameters:
    `channel` -
    `selectSet` -
    `sKey` -
  Returns:
  Throws:
    `IOException`

### connectionFailed

    protected void connectionFailed(SocketChannel channel,
                                    Throwable ex,
                                    Object attachment)

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.