public abstract class AbstractController extends Object implements Controller, ControllerLifeCycle
Modifier and Type | Field and Description |
---|---|
protected CodecFactory |
codecFactory
Codec Factory
|
protected Configuration |
configuration |
protected Dispatcher |
dispatchMessageDispatcher |
protected int |
dispatchMessageThreadCount |
protected Handler |
handler
Event handler
|
protected boolean |
handleReadWriteConcurrently |
protected InetSocketAddress |
localSocketAddress
local bind address
|
protected static org.slf4j.Logger |
log |
protected Dispatcher |
readEventDispatcher |
protected int |
readThreadCount
Read event processing thread count
|
protected Set<Session> |
sessionSet
Connected session set
|
protected long |
sessionTimeout |
protected Map<SocketOption,Object> |
socketOptions
Socket options
|
protected int |
soTimeout |
protected boolean |
started
Status
|
protected CopyOnWriteArrayList<ControllerStateListener> |
stateListeners
controller state listener list
|
protected Statistics |
statistics |
protected long |
statisticsInterval |
protected Dispatcher |
writeEventDispatcher |
protected int |
writeThreadCount |
Constructor and Description |
---|
AbstractController() |
AbstractController(Configuration configuration) |
AbstractController(Configuration configuration,
CodecFactory codecFactory) |
AbstractController(Configuration configuration,
Handler handler,
CodecFactory codecFactory) |
protected Statistics statistics
protected long statisticsInterval
protected static final org.slf4j.Logger log
protected CopyOnWriteArrayList<ControllerStateListener> stateListeners
protected Handler handler
protected CodecFactory codecFactory
protected volatile boolean started
protected InetSocketAddress localSocketAddress
protected int readThreadCount
protected int writeThreadCount
protected int dispatchMessageThreadCount
protected Configuration configuration
protected Dispatcher readEventDispatcher
protected Dispatcher dispatchMessageDispatcher
protected Dispatcher writeEventDispatcher
protected long sessionTimeout
protected boolean handleReadWriteConcurrently
protected int soTimeout
protected Map<SocketOption,Object> socketOptions
public AbstractController()
public AbstractController(Configuration configuration)
public AbstractController(Configuration configuration, CodecFactory codecFactory)
public AbstractController(Configuration configuration, Handler handler, CodecFactory codecFactory)
public void setSocketOptions(Map<SocketOption,Object> socketOptions)
public final int getDispatchMessageThreadCount()
getDispatchMessageThreadCount
in interface Controller
public final void setDispatchMessageThreadCount(int dispatchMessageThreadPoolSize)
setDispatchMessageThreadCount
in interface Controller
public long getSessionIdleTimeout()
getSessionIdleTimeout
in interface Controller
protected Queue<WriteMessage> buildQueue()
public void setSessionIdleTimeout(long sessionIdleTimeout)
setSessionIdleTimeout
in interface Controller
public long getSessionTimeout()
getSessionTimeout
in interface Controller
public void setSessionTimeout(long sessionTimeout)
setSessionTimeout
in interface Controller
public int getSoTimeout()
getSoTimeout
in interface Controller
public void setSoTimeout(int timeout)
setSoTimeout
in interface Controller
public double getReceiveThroughputLimit()
getReceiveThroughputLimit
in interface Controller
public double getSendThroughputLimit()
getSendThroughputLimit
in interface Controller
public void setReceiveThroughputLimit(double receiveThroughputLimit)
setReceiveThroughputLimit
in interface Controller
public void setSendThroughputLimit(double sendThroughputLimit)
setSendThroughputLimit
in interface Controller
public Configuration getConfiguration()
public void setConfiguration(Configuration configuration)
public InetSocketAddress getLocalSocketAddress()
getLocalSocketAddress
in interface Controller
public void setLocalSocketAddress(InetSocketAddress inetSocketAddress)
setLocalSocketAddress
in interface Controller
public void onAccept(SelectionKey sk) throws IOException
IOException
public void onConnect(SelectionKey key) throws IOException
IOException
public void addStateListener(ControllerStateListener listener)
addStateListener
in interface Controller
public void removeStateListener(ControllerStateListener listener)
removeStateListener
in interface Controller
public boolean isHandleReadWriteConcurrently()
isHandleReadWriteConcurrently
in interface Controller
public void setHandleReadWriteConcurrently(boolean handleReadWriteConcurrently)
setHandleReadWriteConcurrently
in interface Controller
public int getReadThreadCount()
getReadThreadCount
in interface Controller
public void setReadThreadCount(int readThreadCount)
setReadThreadCount
in interface Controller
public final int getWriteThreadCount()
getWriteThreadCount
in interface Controller
public final void setWriteThreadCount(int writeThreadCount)
setWriteThreadCount
in interface Controller
public Handler getHandler()
getHandler
in interface Controller
public void setHandler(Handler handler)
setHandler
in interface Controller
public int getPort()
getPort
in interface Controller
public void start() throws IOException
start
in interface Controller
IOException
protected abstract void start0() throws IOException
IOException
public void notifyStarted()
notifyStarted
in interface ControllerLifeCycle
public boolean isStarted()
isStarted
in interface Controller
public final Statistics getStatistics()
getStatistics
in interface Controller
public final CodecFactory getCodecFactory()
getCodecFactory
in interface Controller
public final void setCodecFactory(CodecFactory codecFactory)
setCodecFactory
in interface Controller
public void notifyReady()
notifyReady
in interface ControllerLifeCycle
public final void unregisterSession(Session session)
public void checkStatisticsForRestart()
public final void registerSession(Session session)
public void stop() throws IOException
stop
in interface Controller
IOException
protected abstract void stop0() throws IOException
IOException
public final void notifyException(Throwable t)
notifyException
in interface ControllerLifeCycle
public final void notifyStopped()
notifyStopped
in interface ControllerLifeCycle
public final void notifyAllSessionClosed()
notifyAllSessionClosed
in interface ControllerLifeCycle
public <T> void setSocketOption(SocketOption<T> socketOption, T value)
setSocketOption
in interface Controller
public <T> T getSocketOption(SocketOption<T> socketOption)
public void bind(InetSocketAddress inetSocketAddress) throws IOException
inetSocketAddress
- IOException
Copyright © 2021. All rights reserved.