public class NioEndpoint extends AbstractEndpoint<NioChannel>
Modifier and Type | Class and Description |
---|---|
protected class |
NioEndpoint.Acceptor
The background thread that listens for incoming TCP/IP connections and
hands them off to an appropriate processor.
|
static interface |
NioEndpoint.Handler
Bare bones interface used for socket processing.
|
static class |
NioEndpoint.KeyAttachment |
static class |
NioEndpoint.NioBufferHandler |
class |
NioEndpoint.Poller
Poller class.
|
static class |
NioEndpoint.PollerEvent
PollerEvent, cacheable object for poller events to avoid GC
|
static class |
NioEndpoint.SendfileData
SendfileData class.
|
protected class |
NioEndpoint.SocketProcessor
This class is the equivalent of the Worker, but will simply use in an
external Executor thread pool.
|
AbstractEndpoint.BindState
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.ConcurrentLinkedQueue<NioEndpoint.PollerEvent> |
eventCache
Cache for poller events
|
protected NioEndpoint.Handler |
handler
Handling of accepted sockets.
|
protected java.util.concurrent.ConcurrentLinkedQueue<NioEndpoint.KeyAttachment> |
keyCache
Cache for key attachment objects
|
protected java.util.concurrent.ConcurrentLinkedQueue<NioChannel> |
nioChannels
Bytebuffer cache, each channel holds a set of buffers (two, except for SSL holds four)
|
protected int |
oomParachute
The size of the OOM parachute.
|
protected byte[] |
oomParachuteData
The oom parachute, when an OOM error happens,
will release the data, giving the JVM instantly
a chunk of data to be able to recover with.
|
protected static java.lang.String |
oomParachuteMsg
Make sure this string has already been allocated
|
static int |
OP_CALLBACK |
static int |
OP_REGISTER |
protected java.util.concurrent.atomic.AtomicInteger |
pollerRotater |
protected NioEndpoint.Poller[] |
pollers
The socket poller.
|
protected int |
pollerThreadCount
Poller thread count.
|
protected int |
pollerThreadPriority
Priority of the poller threads.
|
protected java.util.concurrent.ConcurrentLinkedQueue<NioEndpoint.SocketProcessor> |
processorCache
Cache for SocketProcessor objects
|
protected NioSelectorPool |
selectorPool |
protected long |
selectorTimeout |
protected java.nio.channels.ServerSocketChannel |
serverSock
Server socket "pointer".
|
protected javax.net.ssl.SSLContext |
sslContext |
protected java.util.concurrent.CountDownLatch |
stopLatch |
protected boolean |
useComet
Allow comet request handling.
|
protected boolean |
useSendfile
use send file
|
acceptors, acceptorThreadCount, acceptorThreadPriority, attributes, internalExecutor, paused, running, sm, socketProperties, threadPriority
Constructor and Description |
---|
NioEndpoint() |
Modifier and Type | Method and Description |
---|---|
void |
bind()
Initialize the endpoint.
|
protected void |
checkParachute() |
protected AbstractEndpoint.Acceptor |
createAcceptor()
Hook to allow Endpoints to provide a specific Acceptor implementation.
|
protected javax.net.ssl.SSLEngine |
createSSLEngine() |
boolean |
dispatchForEvent(NioChannel socket,
SocketStatus status,
boolean dispatch) |
boolean |
getDeferAccept()
Is deferAccept supported?
|
NioEndpoint.Handler |
getHandler() |
int |
getKeepAliveCount()
Number of keepalive sockets.
|
int |
getLocalPort()
Port in use.
|
protected Log |
getLog() |
int |
getOomParachute() |
byte[] |
getOomParachuteData() |
NioEndpoint.Poller |
getPoller0()
Return an available poller in true round robin fashion
|
int |
getPollerThreadCount() |
int |
getPollerThreadPriority() |
int |
getReadBufSize() |
NioSelectorPool |
getSelectorPool() |
long |
getSelectorTimeout() |
javax.net.ssl.SSLContext |
getSSLContext() |
boolean |
getUseComet() |
boolean |
getUseCometTimeout() |
boolean |
getUsePolling() |
boolean |
getUseSendfile() |
int |
getWriteBufSize() |
protected boolean |
isWorkerAvailable()
Returns true if a worker thread is available for processing.
|
boolean |
processSocket(NioChannel socket,
SocketStatus status,
boolean dispatch) |
void |
processSocketAsync(SocketWrapper<NioChannel> socketWrapper,
SocketStatus socketStatus) |
protected boolean |
reclaimParachute(boolean force) |
protected void |
releaseCaches() |
void |
removeWaitingRequest(SocketWrapper<NioChannel> socketWrapper) |
void |
setHandler(NioEndpoint.Handler handler) |
void |
setOomParachute(int oomParachute) |
void |
setOomParachuteData(byte[] oomParachuteData) |
void |
setPollerThreadCount(int pollerThreadCount) |
void |
setPollerThreadPriority(int pollerThreadPriority) |
boolean |
setProperty(java.lang.String name,
java.lang.String value)
Generic properties, introspected
|
void |
setSelectorPool(NioSelectorPool selectorPool) |
void |
setSelectorTimeout(long timeout) |
protected boolean |
setSocketOptions(java.nio.channels.SocketChannel socket)
Process the specified connection.
|
void |
setSocketProperties(SocketProperties socketProperties) |
void |
setSSLContext(javax.net.ssl.SSLContext c) |
void |
setUseComet(boolean useComet) |
void |
setUseSendfile(boolean useSendfile) |
void |
startInternal()
Start the NIO endpoint, creating acceptor, poller threads.
|
void |
stopInternal()
Stop the endpoint.
|
void |
unbind()
Deallocate NIO memory pools, and close server socket.
|
javax.net.ssl.KeyManager[] |
wrap(javax.net.ssl.KeyManager[] managers) |
configureUseServerCipherSuitesOrder, countDownConnection, countUpOrAwaitConnection, createExecutor, destroy, getAcceptorThreadCount, getAcceptorThreadPriority, getAddress, getAlgorithm, getAllowUnsafeLegacyRenegotiation, getAttribute, getBacklog, getBindOnInit, getCiphers, getClientAuth, getConnectionCount, getCrlFile, getCurrentThreadCount, getCurrentThreadsBusy, getDaemon, getExecutor, getExecutorTerminationTimeoutMillis, getKeepAliveTimeout, getKeyAlias, getKeyPass, getKeystoreFile, getKeystorePass, getKeystoreProvider, getKeystoreType, getMaxConnections, getMaxHeaderCount, getMaxKeepAliveRequests, getMaxThreads, getMaxThreadsExecutor, getMinSpareThreads, getName, getPort, getProperty, getSessionCacheSize, getSessionTimeout, getSocketProperties, getSoLinger, getSoTimeout, getSslEnabledProtocolsArray, getSslProtocol, getTcpNoDelay, getThreadPriority, getTrustManagerClassName, getTrustMaxCertLength, getTruststoreAlgorithm, getTruststoreFile, getTruststorePass, getTruststoreProvider, getTruststoreType, getUseServerCipherSuitesOrder, handleExceptionWithDelay, init, initializeConnectionLatch, isPaused, isRunning, isSSLEnabled, pause, releaseConnectionLatch, resume, setAcceptorThreadCount, setAcceptorThreadPriority, setAddress, setAlgorithm, setAllowUnsafeLegacyRenegotiation, setAttribute, setBacklog, setBindOnInit, setCiphers, setClientAuth, setCrlFile, setDaemon, setExecutor, setExecutorTerminationTimeoutMillis, setKeepAliveTimeout, setKeyAlias, setKeyPass, setKeystoreFile, setKeystorePass, setKeystoreProvider, setKeystoreType, setMaxConnections, setMaxHeaderCount, setMaxKeepAliveRequests, setMaxThreads, setMinSpareThreads, setName, setPort, setSessionCacheSize, setSessionTimeout, setSoLinger, setSoTimeout, setSSLEnabled, setSslEnabledProtocols, setSslProtocol, setTcpNoDelay, setThreadPriority, setTrustManagerClassName, setTrustMaxCertLength, setTruststoreAlgorithm, setTruststoreFile, setTruststorePass, setTruststoreProvider, setTruststoreType, setUseServerCipherSuitesOrder, shutdownExecutor, start, startAcceptorThreads, stop, unlockAccept
public static final int OP_REGISTER
public static final int OP_CALLBACK
protected NioSelectorPool selectorPool
protected java.nio.channels.ServerSocketChannel serverSock
protected boolean useSendfile
protected int oomParachute
protected byte[] oomParachuteData
protected static final java.lang.String oomParachuteMsg
protected volatile java.util.concurrent.CountDownLatch stopLatch
protected java.util.concurrent.ConcurrentLinkedQueue<NioEndpoint.SocketProcessor> processorCache
protected java.util.concurrent.ConcurrentLinkedQueue<NioEndpoint.KeyAttachment> keyCache
protected java.util.concurrent.ConcurrentLinkedQueue<NioEndpoint.PollerEvent> eventCache
protected java.util.concurrent.ConcurrentLinkedQueue<NioChannel> nioChannels
protected int pollerThreadPriority
protected NioEndpoint.Handler handler
protected boolean useComet
protected int pollerThreadCount
protected long selectorTimeout
protected NioEndpoint.Poller[] pollers
protected java.util.concurrent.atomic.AtomicInteger pollerRotater
protected javax.net.ssl.SSLContext sslContext
public boolean setProperty(java.lang.String name, java.lang.String value)
setProperty
in class AbstractEndpoint<NioChannel>
public void setPollerThreadPriority(int pollerThreadPriority)
public int getPollerThreadPriority()
public void setHandler(NioEndpoint.Handler handler)
public NioEndpoint.Handler getHandler()
public void setUseComet(boolean useComet)
public boolean getUseComet()
getUseComet
in class AbstractEndpoint<NioChannel>
public boolean getUseCometTimeout()
getUseCometTimeout
in class AbstractEndpoint<NioChannel>
public boolean getUsePolling()
getUsePolling
in class AbstractEndpoint<NioChannel>
public void setPollerThreadCount(int pollerThreadCount)
public int getPollerThreadCount()
public void setSelectorTimeout(long timeout)
public long getSelectorTimeout()
public NioEndpoint.Poller getPoller0()
public void setSelectorPool(NioSelectorPool selectorPool)
public void setSocketProperties(SocketProperties socketProperties)
public void setUseSendfile(boolean useSendfile)
public boolean getDeferAccept()
getDeferAccept
in class AbstractEndpoint<NioChannel>
public void setOomParachute(int oomParachute)
public void setOomParachuteData(byte[] oomParachuteData)
public javax.net.ssl.SSLContext getSSLContext()
public void setSSLContext(javax.net.ssl.SSLContext c)
public int getLocalPort()
getLocalPort
in class AbstractEndpoint<NioChannel>
protected void checkParachute()
protected boolean reclaimParachute(boolean force)
protected void releaseCaches()
public int getKeepAliveCount()
public void bind() throws java.lang.Exception
bind
in class AbstractEndpoint<NioChannel>
java.lang.Exception
public javax.net.ssl.KeyManager[] wrap(javax.net.ssl.KeyManager[] managers)
public void startInternal() throws java.lang.Exception
startInternal
in class AbstractEndpoint<NioChannel>
java.lang.Exception
public void stopInternal()
stopInternal
in class AbstractEndpoint<NioChannel>
public void unbind() throws java.lang.Exception
unbind
in class AbstractEndpoint<NioChannel>
java.lang.Exception
public int getWriteBufSize()
public int getReadBufSize()
public NioSelectorPool getSelectorPool()
public boolean getUseSendfile()
getUseSendfile
in class AbstractEndpoint<NioChannel>
public int getOomParachute()
public byte[] getOomParachuteData()
protected AbstractEndpoint.Acceptor createAcceptor()
AbstractEndpoint
createAcceptor
in class AbstractEndpoint<NioChannel>
protected boolean setSocketOptions(java.nio.channels.SocketChannel socket)
protected javax.net.ssl.SSLEngine createSSLEngine()
protected boolean isWorkerAvailable()
public void processSocketAsync(SocketWrapper<NioChannel> socketWrapper, SocketStatus socketStatus)
processSocketAsync
in class AbstractEndpoint<NioChannel>
public boolean dispatchForEvent(NioChannel socket, SocketStatus status, boolean dispatch)
public boolean processSocket(NioChannel socket, SocketStatus status, boolean dispatch)
public void removeWaitingRequest(SocketWrapper<NioChannel> socketWrapper)
removeWaitingRequest
in class AbstractEndpoint<NioChannel>
protected Log getLog()
getLog
in class AbstractEndpoint<NioChannel>
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.