Package one.nio.server
Class Server
- java.lang.Object
-
- one.nio.server.Server
-
- All Implemented Interfaces:
ServerMXBean
- Direct Known Subclasses:
HttpServer,RpcServer
public class Server extends Object implements ServerMXBean
-
-
Field Summary
Fields Modifier and Type Field Description protected one.nio.server.AcceptorThread[]acceptorsprotected CleanupThreadcleanupprotected booleancloseSessionsprotected intportprotected SelectorThread[]selectorsprotected CountDownLatchstartSyncprotected booleanuseWorkersprotected one.nio.server.WorkerPoolworkers
-
Constructor Summary
Constructors Constructor Description Server(ServerConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidasyncExecute(Runnable command)protected SessioncreateSession(Socket socket)longgetAcceptedSessions()intgetConnections()longgetKeepAlive()longgetQueueAvgBytes()doublegetQueueAvgLength()longgetQueueMaxBytes()longgetQueueMaxLength()longgetRejectedSessions()longgetRequestsProcessed()longgetRequestsRejected()doublegetSelectorAvgReady()intgetSelectorCount()intgetSelectorMaxReady()longgetSelectorOperations()longgetSelectorSessions()intgetWorkers()intgetWorkersActive()booleangetWorkersUsed()voidincRequestsProcessed()voidincRequestsRejected()voidreconfigure(ServerConfig config)protected voidregister(Session session)voidregisterShutdownHook()voidreset()voidstart()voidstop()
-
-
-
Field Detail
-
port
protected final int port
-
startSync
protected final CountDownLatch startSync
-
acceptors
protected volatile one.nio.server.AcceptorThread[] acceptors
-
selectors
protected volatile SelectorThread[] selectors
-
useWorkers
protected boolean useWorkers
-
workers
protected final one.nio.server.WorkerPool workers
-
cleanup
protected final CleanupThread cleanup
-
closeSessions
protected boolean closeSessions
-
-
Constructor Detail
-
Server
public Server(ServerConfig config) throws IOException
- Throws:
IOException
-
-
Method Detail
-
reconfigure
public void reconfigure(ServerConfig config) throws IOException
- Throws:
IOException
-
start
public void start()
-
stop
public void stop()
-
registerShutdownHook
public void registerShutdownHook()
-
createSession
protected Session createSession(Socket socket) throws RejectedSessionException
- Throws:
RejectedSessionException
-
register
protected void register(Session session)
-
incRequestsProcessed
public final void incRequestsProcessed()
-
incRequestsRejected
public final void incRequestsRejected()
-
getConnections
public int getConnections()
- Specified by:
getConnectionsin interfaceServerMXBean
-
getKeepAlive
public long getKeepAlive()
- Specified by:
getKeepAlivein interfaceServerMXBean
-
getWorkersUsed
public boolean getWorkersUsed()
- Specified by:
getWorkersUsedin interfaceServerMXBean
-
getWorkers
public int getWorkers()
- Specified by:
getWorkersin interfaceServerMXBean
-
getWorkersActive
public int getWorkersActive()
- Specified by:
getWorkersActivein interfaceServerMXBean
-
getAcceptedSessions
public long getAcceptedSessions()
- Specified by:
getAcceptedSessionsin interfaceServerMXBean
-
getRejectedSessions
public long getRejectedSessions()
- Specified by:
getRejectedSessionsin interfaceServerMXBean
-
getSelectorCount
public int getSelectorCount()
- Specified by:
getSelectorCountin interfaceServerMXBean
-
getSelectorAvgReady
public double getSelectorAvgReady()
- Specified by:
getSelectorAvgReadyin interfaceServerMXBean
-
getSelectorMaxReady
public int getSelectorMaxReady()
- Specified by:
getSelectorMaxReadyin interfaceServerMXBean
-
getSelectorOperations
public long getSelectorOperations()
- Specified by:
getSelectorOperationsin interfaceServerMXBean
-
getSelectorSessions
public long getSelectorSessions()
- Specified by:
getSelectorSessionsin interfaceServerMXBean
-
getQueueAvgLength
public double getQueueAvgLength()
- Specified by:
getQueueAvgLengthin interfaceServerMXBean
-
getQueueAvgBytes
public long getQueueAvgBytes()
- Specified by:
getQueueAvgBytesin interfaceServerMXBean
-
getQueueMaxLength
public long getQueueMaxLength()
- Specified by:
getQueueMaxLengthin interfaceServerMXBean
-
getQueueMaxBytes
public long getQueueMaxBytes()
- Specified by:
getQueueMaxBytesin interfaceServerMXBean
-
getRequestsProcessed
public long getRequestsProcessed()
- Specified by:
getRequestsProcessedin interfaceServerMXBean
-
getRequestsRejected
public long getRequestsRejected()
- Specified by:
getRequestsRejectedin interfaceServerMXBean
-
reset
public void reset()
- Specified by:
resetin interfaceServerMXBean
-
asyncExecute
public final void asyncExecute(Runnable command)
-
-