org.eclipse.jetty.io.nio
Class SelectorManager

java.lang.Object
  extended by org.eclipse.jetty.util.component.AbstractLifeCycle
      extended by org.eclipse.jetty.io.nio.SelectorManager
All Implemented Interfaces:
Dumpable, LifeCycle

public abstract class SelectorManager
extends AbstractLifeCycle
implements Dumpable

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


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
static Logger LOG
           
 
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
Constructor Summary
SelectorManager()
           
 
Method Summary
protected  void connectionFailed(SocketChannel channel, Throwable ex, Object attachment)
           
abstract  boolean dispatch(Runnable task)
           
protected  void doStart()
           
protected  void doStop()
           
 String dump()
           
 void dump(Appendable out, String indent)
           
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()
           
 int getSelectorPriorityDelta()
           
 SelectorManager.SelectSet getSelectSet(int i)
           
 int getSelectSets()
           
 boolean isDeferringInterestedOps0()
           
abstract  AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment)
           
protected abstract  SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey sKey)
          Create a new end point
 void register(ServerSocketChannel acceptChannel)
          Register a ServerSocketChannel
 void register(SocketChannel channel)
          Register a channel
 void register(SocketChannel channel, Object att)
          Register a channel
 void setDeferringInterestedOps0(boolean deferringInterestedOps0)
           
 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 setSelectorPriorityDelta(int delta)
          Set the selector thread priorty delta.
 void setSelectSets(int selectSets)
           
 
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

public static final Logger LOG
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(SocketChannel channel,
                     Object att)
Register a channel

Parameters:
channel -
att - Attached Object

register

public void register(SocketChannel channel)
Register a channel

Parameters:
channel -

register

public void register(ServerSocketChannel acceptChannel)
Register a ServerSocketChannel

Parameters:
acceptChannel -

getSelectorPriorityDelta

public int getSelectorPriorityDelta()
Returns:
delta The value to add to the selector thread priority.

setSelectorPriorityDelta

public void setSelectorPriorityDelta(int delta)
Set the selector thread priorty delta.

Parameters:
delta - The value to add to the selector thread priority.

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)

dispatch

public abstract boolean dispatch(Runnable task)

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

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

public abstract AsyncConnection newConnection(SocketChannel channel,
                                              AsyncEndPoint endpoint,
                                              Object attachment)

newEndPoint

protected abstract SelectChannelEndPoint newEndPoint(SocketChannel channel,
                                                     SelectorManager.SelectSet selectSet,
                                                     SelectionKey sKey)
                                              throws IOException
Create a new end point

Parameters:
channel -
selectSet -
sKey - the selection key
Returns:
the new endpoint SelectChannelEndPoint
Throws:
IOException

connectionFailed

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

dump

public String dump()
Specified by:
dump in interface Dumpable

dump

public void dump(Appendable out,
                 String indent)
          throws IOException
Specified by:
dump in interface Dumpable
Throws:
IOException

isDeferringInterestedOps0

public boolean isDeferringInterestedOps0()

setDeferringInterestedOps0

public void setDeferringInterestedOps0(boolean deferringInterestedOps0)


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