Package org.eclipse.jetty.io
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:
Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
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 ClassesModifier and TypeClassDescription(package private) class
(package private) class
private class
(package private) class
private final class
private class
private static class
static interface
AManagedSelector.Selectable
is anEndPoint
that wish to be notified of non-blocking events by theManagedSelector
.private class
static interface
A selector update to be done when the selector has been woken.private class
private class
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.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
private final SampleStatistic
private boolean
private Selector
private final SelectorManager
private final AtomicBoolean
private final ExecutionStrategy
private Deque
<ManagedSelector.SelectorUpdate> private Deque
<ManagedSelector.SelectorUpdate> private static final boolean
private static final Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
createEndPoint
(SelectableChannel channel, SelectionKey selectionKey) (package private) void
destroyEndPoint
(EndPoint endPoint) protected void
doStart()
Starts the managed lifecycle beans in the order they were added.protected void
doStop()
Stops the managed lifecycle beans in the reverse order they were added.void
dump
(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.protected void
endPointClosed
(EndPoint endPoint) protected void
endPointOpened
(EndPoint endPoint) private void
private int
double
double
long
int
protected void
handleSelectFailure
(Selector selector, Throwable failure) protected int
protected void
onSelectFailed
(Throwable cause) private void
processConnect
(SelectionKey key, ManagedSelector.Connect connect) void
(package private) static int
safeInterestOps
(SelectionKey selectionKey) (package private) static int
safeReadyOps
(SelectionKey selectionKey) protected int
int
size()
void
submit
(ManagedSelector.SelectorUpdate update) Submit anManagedSelector.SelectorUpdate
to be acted on between calls toSelector.select()
private void
submit
(ManagedSelector.SelectorUpdate update, boolean lazy) toString()
private void
wakeup()
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, 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.Dumpable.DumpableContainer
isDumpable
-
Field Details
-
LOG
-
FORCE_SELECT_NOW
private static final boolean FORCE_SELECT_NOW -
_started
-
_selecting
private boolean _selecting -
_selectorManager
-
_id
private final int _id -
_strategy
-
_selector
-
_updates
-
_updateable
-
_keyStats
-
-
Constructor Details
-
ManagedSelector
-
-
Method Details
-
getSelector
-
doStart
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classContainerLifeCycle
- Throws:
Exception
-
doStop
Description copied from class:ContainerLifeCycle
Stops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStop
in classContainerLifeCycle
- Throws:
Exception
-
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 double getMaxSelectedKeys() -
getSelectCount
@ManagedAttribute(value="Total number of select() calls", readonly=true) public long getSelectCount() -
resetStats
-
nioSelect
- Throws:
IOException
-
select
- Throws:
IOException
-
handleSelectFailure
- Throws:
IOException
-
onSelectFailed
-
size
public int size() -
submit
Submit anManagedSelector.SelectorUpdate
to be acted on between calls toSelector.select()
- Parameters:
update
- The selector update to apply at next wakeup
-
submit
-
wakeup
private void wakeup() -
execute
-
processConnect
-
endPointOpened
-
endPointClosed
-
createEndPoint
private void createEndPoint(SelectableChannel channel, SelectionKey selectionKey) throws IOException - Throws:
IOException
-
destroyEndPoint
-
getActionSize
private int getActionSize() -
safeReadyOps
-
safeInterestOps
-
dump
Description copied from interface:Dumpable
Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dump
in interfaceDumpable
- Overrides:
dump
in classContainerLifeCycle
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
IOException
- if unable to write to Appendable
-
toString
- Overrides:
toString
in classAbstractLifeCycle
-