Class ManagedSelector

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.io.ManagedSelector
All Implemented Interfaces:
org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle

public class ManagedSelector extends org.eclipse.jetty.util.component.ContainerLifeCycle implements org.eclipse.jetty.util.component.Dumpable

ManagedSelector wraps a Selector simplifying non-blocking operations on channels.

ManagedSelector runs the select loop, which waits on Selector.select() until events happen for registered channels. When events happen, it notifies the EndPoint associated with the channel.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    A ManagedSelector.Selectable is an EndPoint that wish to be notified of non-blocking events by the ManagedSelector.
    static interface 
    A selector update to be done when the selector has been woken.

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

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

    org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

    org.eclipse.jetty.util.component.Dumpable.DumpableContainer

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

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • Field Summary

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, STARTED, STARTING, STOPPED, STOPPING

    Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

    KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
    ManagedSelector(SelectorManager selectorManager, int id)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    protected void
     
    void
    dump(Appendable out, String indent)
     
    protected void
     
    protected void
     
    double
     
    long
     
    long
     
     
    int
     
    protected void
     
    protected int
    nioSelect(Selector selector, boolean now)
     
    protected void
     
    void
     
    protected int
    select(Selector selector)
     
    int
     
    void
    Submit an ManagedSelector.SelectorUpdate to be acted on between calls to Selector.select()
     

    Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle

    addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans

    Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.jetty.util.component.Container

    getCachedBeans, getEventListeners

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

    dump, dumpSelf

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    isDumpable
  • Constructor Details

    • ManagedSelector

      public ManagedSelector(SelectorManager selectorManager, int id)
  • Method Details

    • getSelector

      public Selector getSelector()
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      Exception
    • getTotalKeys

      @ManagedAttribute(value="Total number of keys", readonly=true) public int getTotalKeys()
    • getAverageSelectedKeys

      @ManagedAttribute(value="Average number of selected keys", readonly=true) public double getAverageSelectedKeys()
    • getMaxSelectedKeys

      @ManagedAttribute(value="Maximum number of selected keys", readonly=true) public long getMaxSelectedKeys()
    • getSelectCount

      @ManagedAttribute(value="Total number of select() calls", readonly=true) public long getSelectCount()
    • resetStats

      @ManagedOperation(value="Resets the statistics", impact="ACTION") public void resetStats()
    • nioSelect

      protected int nioSelect(Selector selector, boolean now) throws IOException
      Throws:
      IOException
    • select

      protected int select(Selector selector) throws IOException
      Throws:
      IOException
    • handleSelectFailure

      protected void handleSelectFailure(Selector selector, Throwable failure) throws IOException
      Throws:
      IOException
    • onSelectFailed

      protected void onSelectFailed(Throwable cause)
    • size

      public int size()
    • submit

      public void submit(ManagedSelector.SelectorUpdate update)
      Submit an ManagedSelector.SelectorUpdate to be acted on between calls to Selector.select()
      Parameters:
      update - The selector update to apply at next wakeup
    • endPointOpened

      protected void endPointOpened(EndPoint endPoint)
    • endPointClosed

      protected void endPointClosed(EndPoint endPoint)
    • dump

      public void dump(Appendable out, String indent) throws IOException
      Specified by:
      dump in interface org.eclipse.jetty.util.component.Dumpable
      Overrides:
      dump in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class org.eclipse.jetty.util.component.AbstractLifeCycle