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 int
backlog
Accept backlog queue sizeprivate int
bandwidth
private int
connectionTime
private int
latency
private java.nio.channels.ServerSocketChannel
serverSocketChannel
-
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 void
closeAcceptChannel(java.nio.channels.SelectionKey sk, java.nio.channels.SocketChannel sc)
void
closeChannel(java.nio.channels.Selector selector)
protected void
doStart()
Inner startupint
getBacklog()
void
onAccept(java.nio.channels.SelectionKey selectionKey)
void
setBacklog(int backlog)
void
setPerformancePreferences(int connectionTime, int latency, int bandwidth)
void
unbind()
-
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.IOException
Description copied from class:NioController
Inner startup- Specified by:
doStart
in classNioController
- Throws:
java.io.IOException
-
onAccept
public void onAccept(java.nio.channels.SelectionKey selectionKey) throws java.io.IOException
- Specified by:
onAccept
in interfaceSelectionKeyHandler
- Overrides:
onAccept
in 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.IOException
java.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
-
-