Package com.google.code.yanf4j.nio
Class TCPController
- java.lang.Object
-
- com.google.code.yanf4j.core.impl.AbstractController
-
- com.google.code.yanf4j.nio.impl.NioController
-
- com.google.code.yanf4j.nio.impl.SocketChannelController
-
- com.google.code.yanf4j.nio.TCPController
-
- All Implemented Interfaces:
Controller,ControllerLifeCycle,SelectionKeyHandler
public class TCPController extends SocketChannelController
Controller for tcp server
-
-
Field Summary
Fields Modifier and Type Field Description private intbacklogAccept backlog queue sizeprivate intbandwidthprivate intconnectionTimeprivate intlatencyprivate java.nio.channels.ServerSocketChannelserverSocketChannel-
Fields inherited from class com.google.code.yanf4j.nio.impl.SocketChannelController
soLingerOn
-
Fields inherited from class com.google.code.yanf4j.nio.impl.NioController
selectorManager, selectorPoolSize
-
Fields 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
Constructors Constructor Description TCPController()TCPController(Configuration configuration)TCPController(Configuration configuration, CodecFactory codecFactory)TCPController(Configuration configuration, Handler handler, CodecFactory codecFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcloseAcceptChannel(java.nio.channels.SelectionKey sk, java.nio.channels.SocketChannel sc)voidcloseChannel(java.nio.channels.Selector selector)protected voiddoStart()Inner startupintgetBacklog()voidonAccept(java.nio.channels.SelectionKey selectionKey)voidsetBacklog(int backlog)voidsetPerformancePreferences(int connectionTime, int latency, int bandwidth)voidunbind()-
Methods inherited from class com.google.code.yanf4j.nio.impl.SocketChannelController
buildSession, configureSocketChannel, dispatchReadEvent, dispatchWriteEvent, setSoLinger
-
Methods inherited from class com.google.code.yanf4j.nio.impl.NioController
bind, buildSessionConfig, closeSelectionKey, getSelectorManager, getSelectorPoolSize, initialSelectorManager, onRead, onWrite, setSelectorPoolSize, start0, stop0
-
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, onConnect, registerSession, removeStateListener, setCodecFactory, setConfiguration, setDispatchMessageThreadCount, setHandler, setHandleReadWriteConcurrently, setLocalSocketAddress, setReadThreadCount, setReceiveThroughputLimit, setSendThroughputLimit, setSessionIdleTimeout, setSessionTimeout, setSocketOption, setSocketOptions, setSoTimeout, setWriteThreadCount, start, stop, unregisterSession
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.code.yanf4j.nio.SelectionKeyHandler
onConnect
-
-
-
-
Constructor Detail
-
TCPController
public TCPController()
-
TCPController
public TCPController(Configuration configuration)
-
TCPController
public TCPController(Configuration configuration, CodecFactory codecFactory)
-
TCPController
public TCPController(Configuration configuration, Handler handler, CodecFactory codecFactory)
-
-
Method Detail
-
getBacklog
public int getBacklog()
-
setBacklog
public void setBacklog(int backlog)
-
setPerformancePreferences
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth)
-
doStart
protected void doStart() throws java.io.IOExceptionDescription copied from class:NioControllerInner startup- Specified by:
doStartin classNioController- Throws:
java.io.IOException
-
onAccept
public void onAccept(java.nio.channels.SelectionKey selectionKey) throws java.io.IOException- Specified by:
onAcceptin interfaceSelectionKeyHandler- Overrides:
onAcceptin classAbstractController- Throws:
java.io.IOException
-
closeAcceptChannel
private void closeAcceptChannel(java.nio.channels.SelectionKey sk, java.nio.channels.SocketChannel sc) throws java.io.IOException, java.net.SocketException- Parameters:
sk-sc-- Throws:
java.io.IOExceptionjava.net.SocketException
-
closeChannel
public void closeChannel(java.nio.channels.Selector selector) throws java.io.IOException- Throws:
java.io.IOException
-
unbind
public void unbind() throws java.io.IOException- Throws:
java.io.IOException
-
-