Package com.google.code.yanf4j.nio.impl
Class NioController
java.lang.Object
com.google.code.yanf4j.core.impl.AbstractController
com.google.code.yanf4j.nio.impl.NioController
- All Implemented Interfaces:
Controller,ControllerLifeCycle,SelectionKeyHandler
- Direct Known Subclasses:
SocketChannelController
Base nio controller
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classRead taskprivate final classWrite task -
Field Summary
FieldsFields inherited from class com.google.code.yanf4j.core.impl.AbstractController
codecFactory, configuration, dispatchMessageDispatcher, dispatchMessageThreadCount, handler, handleReadWriteConcurrently, localSocketAddress, log, readEventDispatcher, readThreadCount, sessionSet, sessionTimeout, socketOptions, soTimeout, started, stateListeners, statistics, statisticsInterval, writeEventDispatcher, writeThreadCount -
Constructor Summary
ConstructorsConstructorDescriptionNioController(Configuration configuration) NioController(Configuration configuration, CodecFactory codecFactory) NioController(Configuration configuration, Handler handler, CodecFactory codecFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidbind(int port) protected final NioSessionConfigbuildSessionConfig(SelectableChannel sc, Queue<WriteMessage> queue) Build nio session configvoidCancel selection keyprotected abstract voidDispatch read eventprotected abstract voidDispatch write eventprotected abstract voiddoStart()Inner startupfinal SelectorManagerintprotected voidStart selector managervoidonRead(SelectionKey key) Read event occuredvoidonWrite(SelectionKey key) Writable event occuredvoidsetSelectorPoolSize(int selectorPoolSize) protected voidstart0()protected voidstop0()Methods inherited from class com.google.code.yanf4j.core.impl.AbstractController
addStateListener, bind, buildQueue, checkStatisticsForRestart, getCodecFactory, getConfiguration, getDispatchMessageThreadCount, getHandler, getLocalSocketAddress, getPort, getReadThreadCount, getReceiveThroughputLimit, getSendThroughputLimit, getSessionIdleTimeout, getSessionSet, getSessionTimeout, getSocketOption, getSoTimeout, getStatistics, getWriteThreadCount, isHandleReadWriteConcurrently, isStarted, notifyAllSessionClosed, notifyException, notifyReady, notifyStarted, notifyStopped, onAccept, onConnect, registerSession, removeStateListener, setCodecFactory, setConfiguration, setDispatchMessageThreadCount, setHandler, setHandleReadWriteConcurrently, setLocalSocketAddress, setReadThreadCount, setReceiveThroughputLimit, setSendThroughputLimit, setSessionIdleTimeout, setSessionTimeout, setSocketOption, setSocketOptions, setSoTimeout, setWriteThreadCount, start, stop, unregisterSessionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.code.yanf4j.nio.SelectionKeyHandler
closeChannel, onAccept, onConnect
-
Field Details
-
selectorManager
-
selectorPoolSize
protected int selectorPoolSizeReactor count
-
-
Constructor Details
-
NioController
public NioController() -
NioController
-
NioController
-
NioController
-
-
Method Details
-
getSelectorPoolSize
public int getSelectorPoolSize()- Returns:
- See Also:
-
setSelectorPoolSize
public void setSelectorPoolSize(int selectorPoolSize) -
getSelectorManager
-
start0
- Specified by:
start0in classAbstractController- Throws:
IOException
-
initialSelectorManager
Start selector manager- Throws:
IOException
-
doStart
Inner startup- Throws:
IOException
-
onRead
Read event occured- Specified by:
onReadin interfaceSelectionKeyHandler
-
onWrite
Writable event occured- Specified by:
onWritein interfaceSelectionKeyHandler
-
closeSelectionKey
Cancel selection key- Specified by:
closeSelectionKeyin interfaceSelectionKeyHandler
-
dispatchReadEvent
Dispatch read event- Parameters:
key-
-
dispatchWriteEvent
Dispatch write event- Parameters:
key-
-
stop0
- Specified by:
stop0in classAbstractController- Throws:
IOException
-
bind
- Throws:
IOException
-
buildSessionConfig
protected final NioSessionConfig buildSessionConfig(SelectableChannel sc, Queue<WriteMessage> queue) Build nio session config- Parameters:
sc-queue-- Returns:
-