org.apache.tomcat.util.net

Class AprEndpoint

public class AprEndpoint extends Object

APR tailored thread pool, providing the following services: When switching to Java 5, there's an opportunity to use the virtual machine's thread pool.

Author: Mladen Turk Remy Maucherat

Nested Class Summary
protected classAprEndpoint.Acceptor
Server socket acceptor thread.
interfaceAprEndpoint.Handler
Bare bones interface used for socket processing.
classAprEndpoint.Poller
Poller class.
classAprEndpoint.Sendfile
Sendfile class.
static classAprEndpoint.SendfileData
SendfileData class.
protected classAprEndpoint.SocketEventProcessor
This class is the equivalent of the Worker, but will simply use in an external Executor thread pool.
protected classAprEndpoint.SocketProcessor
This class is the equivalent of the Worker, but will simply use in an external Executor thread pool.
protected classAprEndpoint.SocketWithOptionsProcessor
This class is the equivalent of the Worker, but will simply use in an external Executor thread pool.
protected classAprEndpoint.Worker
Server processor class.
classAprEndpoint.WorkerStack
Field Summary
protected intacceptorThreadCount
Acceptor thread count.
protected InetAddressaddress
Address for the server socket.
protected intbacklog
Allows the server developer to specify the backlog that should be used for server sockets.
protected intcometPollerRoundRobin
protected AprEndpoint.Poller[]cometPollers
The socket poller used for Comet support.
protected intcurThreads
Current worker threads count.
protected intcurThreadsBusy
Current worker threads busy count.
static StringCERTIFICATE_KEY
The Request attribute key for the client certificate chain.
static StringCIPHER_SUITE_KEY
The Request attribute key for the cipher suite.
protected booleandaemon
The default is true - the created threads will be in daemon mode.
protected booleandeferAccept
Defer accept.
protected Executorexecutor
External Executor based thread pool.
protected AprEndpoint.Handlerhandler
Handling of accepted sockets.
protected booleaninitialized
Track the initialization state of the endpoint.
protected intkeepAliveTimeout
Keep-Alive timeout.
static StringKEY_SIZE_KEY
The Request attribute key for the key size.
protected static Loglog
protected intmaxThreads
Maximum amount of worker threads.
protected Stringname
Name of the thread pool, which will be used for naming child threads.
protected booleanpaused
Will be set to true whenever the endpoint is paused.
protected intpollerRoundRobin
protected AprEndpoint.Poller[]pollers
The socket poller.
protected intpollerSize
Size of the socket poller.
protected intpollerThreadCount
Poller thread count.
protected intpollTime
Poll interval, in microseconds.
protected intport
Server socket port.
protected longrootPool
Root APR memory pool.
protected booleanrunning
Running state of the endpoint.
protected intsendfileRoundRobin
protected AprEndpoint.Sendfile[]sendfiles
The static file sender.
protected intsendfileSize
Size of the sendfile (= concurrent files which can be served).
protected intsendfileThreadCount
Sendfile thread count.
protected intsequence
Sequence number used to generate thread names.
protected longserverSock
Server socket "pointer".
protected longserverSockPool
APR memory pool for the server socket.
protected static StringManagersm
protected intsoLinger
Socket linger.
protected intsoTimeout
Socket timeout.
protected longsslContext
SSL context.
static StringSESSION_ID_KEY
The Request attribute key for the session id.
protected StringSSLCACertificateFile
SSL CA certificate file.
protected StringSSLCACertificatePath
SSL CA certificate path.
protected StringSSLCARevocationFile
SSL CA revocation file.
protected StringSSLCARevocationPath
SSL CA revocation path.
protected StringSSLCertificateChainFile
SSL certificate chain file.
protected StringSSLCertificateFile
SSL certificate file.
protected StringSSLCertificateKeyFile
SSL certificate key file.
protected StringSSLCipherSuite
SSL cipher suite.
protected booleanSSLEnabled
SSL engine.
protected StringSSLPassword
SSL password (if a cert is encrypted, and no password has been provided, a callback will ask for a password).
protected StringSSLProtocol
SSL protocols.
protected StringSSLVerifyClient
SSL verify client.
protected intSSLVerifyDepth
SSL verify depth.
protected booleantcpNoDelay
Socket TCP no delay.
protected intthreadPriority
Priority of the acceptor and poller threads.
protected intunlockTimeout
Unlock timeout.
protected booleanuseComet
Allow comet request handling.
protected booleanuseSendfile
Use endfile for sending static files.
protected AprEndpoint.WorkerStackworkers
Available workers.
Method Summary
protected longallocatePoller(int size, long pool, int timeout)
Allocate a new poller of the specified size.
protected AprEndpoint.WorkercreateWorkerThread()
Create (or allocate) and return an available processor for use in processing a specific HTTP request, if possible.
voiddestroy()
Deallocate APR memory pools, and close server socket.
intgetAcceptorThreadCount()
InetAddressgetAddress()
intgetBacklog()
AprEndpoint.PollergetCometPoller()
intgetCurrentThreadCount()
Return the amount of threads that are managed by the pool.
intgetCurrentThreadsBusy()
Return the amount of threads that are in use
booleangetDaemon()
booleangetDeferAccept()
ExecutorgetExecutor()
AprEndpoint.HandlergetHandler()
intgetKeepAliveCount()
Number of keepalive sockets.
intgetKeepAliveTimeout()
intgetMaxSpareThreads()
Dummy maxSpareThreads property.
intgetMaxThreads()
intgetMinSpareThreads()
Dummy minSpareThreads property.
StringgetName()
AprEndpoint.PollergetPoller()
intgetPollerSize()
intgetPollerThreadCount()
intgetPollTime()
intgetPort()
AprEndpoint.SendfilegetSendfile()
intgetSendfileCount()
Number of sendfile sockets.
intgetSendfileSize()
intgetSendfileThreadCount()
protected intgetSequence()
Get a sequence number used for thread naming.
intgetSoLinger()
intgetSoTimeout()
StringgetSSLCACertificateFile()
StringgetSSLCACertificatePath()
StringgetSSLCARevocationFile()
StringgetSSLCARevocationPath()
StringgetSSLCertificateChainFile()
StringgetSSLCertificateFile()
StringgetSSLCertificateKeyFile()
StringgetSSLCipherSuite()
StringgetSSLPassword()
StringgetSSLProtocol()
StringgetSSLVerifyClient()
intgetSSLVerifyDepth()
booleangetTcpNoDelay()
intgetThreadPriority()
intgetUnlockTimeout()
booleangetUseComet()
booleangetUseSendfile()
protected AprEndpoint.WorkergetWorkerThread()
Return a new worker thread, and block while to worker is available.
voidinit()
Initialize the endpoint.
booleanisPaused()
Return the state of the endpoint.
booleanisRunning()
Return the state of the endpoint.
booleanisSSLEnabled()
protected AprEndpoint.WorkernewWorkerThread()
Create and return a new processor suitable for processing HTTP requests and returning the corresponding responses.
voidpause()
Pause the endpoint, which will make it stop accepting new sockets.
protected booleanprocessSocket(long socket)
Process given socket.
protected booleanprocessSocket(long socket, SocketStatus status)
Process given socket for an event.
protected booleanprocessSocketWithOptions(long socket)
Process given socket.
protected voidrecycleWorkerThread(AprEndpoint.Worker workerThread)
Recycle the specified Processor so that it can be used again.
voidresume()
Resume the endpoint, which will make it start accepting new sockets again.
voidsetAcceptorThreadCount(int acceptorThreadCount)
voidsetAddress(InetAddress address)
voidsetBacklog(int backlog)
voidsetDaemon(boolean b)
voidsetDeferAccept(boolean deferAccept)
voidsetExecutor(Executor executor)
voidsetHandler(AprEndpoint.Handler handler)
voidsetKeepAliveTimeout(int keepAliveTimeout)
voidsetMaxThreads(int maxThreads)
voidsetName(String name)
voidsetPollerSize(int pollerSize)
voidsetPollerThreadCount(int pollerThreadCount)
voidsetPollTime(int pollTime)
voidsetPort(int port)
voidsetSendfileSize(int sendfileSize)
voidsetSendfileThreadCount(int sendfileThreadCount)
protected booleansetSocketOptions(long socket)
Process the specified connection.
voidsetSoLinger(int soLinger)
voidsetSoTimeout(int soTimeout)
voidsetSSLCACertificateFile(String SSLCACertificateFile)
voidsetSSLCACertificatePath(String SSLCACertificatePath)
voidsetSSLCARevocationFile(String SSLCARevocationFile)
voidsetSSLCARevocationPath(String SSLCARevocationPath)
voidsetSSLCertificateChainFile(String SSLCertificateChainFile)
voidsetSSLCertificateFile(String SSLCertificateFile)
voidsetSSLCertificateKeyFile(String SSLCertificateKeyFile)
voidsetSSLCipherSuite(String SSLCipherSuite)
voidsetSSLEnabled(boolean SSLEnabled)
voidsetSSLPassword(String SSLPassword)
voidsetSSLProtocol(String SSLProtocol)
voidsetSSLVerifyClient(String SSLVerifyClient)
voidsetSSLVerifyDepth(int SSLVerifyDepth)
voidsetTcpNoDelay(boolean tcpNoDelay)
voidsetThreadPriority(int threadPriority)
voidsetUnlockTimeout(int unlockTimeout)
voidsetUseComet(boolean useComet)
voidsetUseSendfile(boolean useSendfile)
voidstart()
Start the APR endpoint, creating acceptor, poller and sendfile threads.
voidstop()
Stop the endpoint.
protected voidunlockAccept()
Unlock the server socket accept using a bugus connection.

Field Detail

acceptorThreadCount

protected int acceptorThreadCount
Acceptor thread count.

address

protected InetAddress address
Address for the server socket.

backlog

protected int backlog
Allows the server developer to specify the backlog that should be used for server sockets. By default, this value is 100.

cometPollerRoundRobin

protected int cometPollerRoundRobin

cometPollers

protected AprEndpoint.Poller[] cometPollers
The socket poller used for Comet support.

curThreads

protected int curThreads
Current worker threads count.

curThreadsBusy

protected int curThreadsBusy
Current worker threads busy count.

CERTIFICATE_KEY

public static final String CERTIFICATE_KEY
The Request attribute key for the client certificate chain.

CIPHER_SUITE_KEY

public static final String CIPHER_SUITE_KEY
The Request attribute key for the cipher suite.

daemon

protected boolean daemon
The default is true - the created threads will be in daemon mode. If set to false, the control thread will not be daemon - and will keep the process alive.

deferAccept

protected boolean deferAccept
Defer accept.

executor

protected Executor executor
External Executor based thread pool.

handler

protected AprEndpoint.Handler handler
Handling of accepted sockets.

initialized

protected boolean initialized
Track the initialization state of the endpoint.

keepAliveTimeout

protected int keepAliveTimeout
Keep-Alive timeout.

KEY_SIZE_KEY

public static final String KEY_SIZE_KEY
The Request attribute key for the key size.

log

protected static Log log

maxThreads

protected int maxThreads
Maximum amount of worker threads.

name

protected String name
Name of the thread pool, which will be used for naming child threads.

paused

protected volatile boolean paused
Will be set to true whenever the endpoint is paused.

pollerRoundRobin

protected int pollerRoundRobin

pollers

protected AprEndpoint.Poller[] pollers
The socket poller.

pollerSize

protected int pollerSize
Size of the socket poller.

pollerThreadCount

protected int pollerThreadCount
Poller thread count.

pollTime

protected int pollTime
Poll interval, in microseconds. The smaller the value, the more CPU the poller will use, but the more responsive to activity it will be.

port

protected int port
Server socket port.

rootPool

protected long rootPool
Root APR memory pool.

running

protected volatile boolean running
Running state of the endpoint.

sendfileRoundRobin

protected int sendfileRoundRobin

sendfiles

protected AprEndpoint.Sendfile[] sendfiles
The static file sender.

sendfileSize

protected int sendfileSize
Size of the sendfile (= concurrent files which can be served).

sendfileThreadCount

protected int sendfileThreadCount
Sendfile thread count.

sequence

protected int sequence
Sequence number used to generate thread names.

serverSock

protected long serverSock
Server socket "pointer".

serverSockPool

protected long serverSockPool
APR memory pool for the server socket.

sm

protected static StringManager sm

soLinger

protected int soLinger
Socket linger.

soTimeout

protected int soTimeout
Socket timeout.

sslContext

protected long sslContext
SSL context.

SESSION_ID_KEY

public static final String SESSION_ID_KEY
The Request attribute key for the session id. This one is a Tomcat extension to the Servlet spec.

SSLCACertificateFile

protected String SSLCACertificateFile
SSL CA certificate file.

SSLCACertificatePath

protected String SSLCACertificatePath
SSL CA certificate path.

SSLCARevocationFile

protected String SSLCARevocationFile
SSL CA revocation file.

SSLCARevocationPath

protected String SSLCARevocationPath
SSL CA revocation path.

SSLCertificateChainFile

protected String SSLCertificateChainFile
SSL certificate chain file.

SSLCertificateFile

protected String SSLCertificateFile
SSL certificate file.

SSLCertificateKeyFile

protected String SSLCertificateKeyFile
SSL certificate key file.

SSLCipherSuite

protected String SSLCipherSuite
SSL cipher suite.

SSLEnabled

protected boolean SSLEnabled
SSL engine.

SSLPassword

protected String SSLPassword
SSL password (if a cert is encrypted, and no password has been provided, a callback will ask for a password).

SSLProtocol

protected String SSLProtocol
SSL protocols.

SSLVerifyClient

protected String SSLVerifyClient
SSL verify client.

SSLVerifyDepth

protected int SSLVerifyDepth
SSL verify depth.

tcpNoDelay

protected boolean tcpNoDelay
Socket TCP no delay.

threadPriority

protected int threadPriority
Priority of the acceptor and poller threads.

unlockTimeout

protected int unlockTimeout
Unlock timeout.

useComet

protected boolean useComet
Allow comet request handling.

useSendfile

protected boolean useSendfile
Use endfile for sending static files.

workers

protected AprEndpoint.WorkerStack workers
Available workers.

Method Detail

allocatePoller

protected long allocatePoller(int size, long pool, int timeout)
Allocate a new poller of the specified size.

createWorkerThread

protected AprEndpoint.Worker createWorkerThread()
Create (or allocate) and return an available processor for use in processing a specific HTTP request, if possible. If the maximum allowed processors have already been created and are in use, return null instead.

destroy

public void destroy()
Deallocate APR memory pools, and close server socket.

getAcceptorThreadCount

public int getAcceptorThreadCount()

getAddress

public InetAddress getAddress()

getBacklog

public int getBacklog()

getCometPoller

public AprEndpoint.Poller getCometPoller()

getCurrentThreadCount

public int getCurrentThreadCount()
Return the amount of threads that are managed by the pool.

Returns: the amount of threads that are managed by the pool

getCurrentThreadsBusy

public int getCurrentThreadsBusy()
Return the amount of threads that are in use

Returns: the amount of threads that are in use

getDaemon

public boolean getDaemon()

getDeferAccept

public boolean getDeferAccept()

getExecutor

public Executor getExecutor()

getHandler

public AprEndpoint.Handler getHandler()

getKeepAliveCount

public int getKeepAliveCount()
Number of keepalive sockets.

getKeepAliveTimeout

public int getKeepAliveTimeout()

getMaxSpareThreads

public int getMaxSpareThreads()
Dummy maxSpareThreads property.

getMaxThreads

public int getMaxThreads()

getMinSpareThreads

public int getMinSpareThreads()
Dummy minSpareThreads property.

getName

public String getName()

getPoller

public AprEndpoint.Poller getPoller()

getPollerSize

public int getPollerSize()

getPollerThreadCount

public int getPollerThreadCount()

getPollTime

public int getPollTime()

getPort

public int getPort()

getSendfile

public AprEndpoint.Sendfile getSendfile()

getSendfileCount

public int getSendfileCount()
Number of sendfile sockets.

getSendfileSize

public int getSendfileSize()

getSendfileThreadCount

public int getSendfileThreadCount()

getSequence

protected int getSequence()
Get a sequence number used for thread naming.

getSoLinger

public int getSoLinger()

getSoTimeout

public int getSoTimeout()

getSSLCACertificateFile

public String getSSLCACertificateFile()

getSSLCACertificatePath

public String getSSLCACertificatePath()

getSSLCARevocationFile

public String getSSLCARevocationFile()

getSSLCARevocationPath

public String getSSLCARevocationPath()

getSSLCertificateChainFile

public String getSSLCertificateChainFile()

getSSLCertificateFile

public String getSSLCertificateFile()

getSSLCertificateKeyFile

public String getSSLCertificateKeyFile()

getSSLCipherSuite

public String getSSLCipherSuite()

getSSLPassword

public String getSSLPassword()

getSSLProtocol

public String getSSLProtocol()

getSSLVerifyClient

public String getSSLVerifyClient()

getSSLVerifyDepth

public int getSSLVerifyDepth()

getTcpNoDelay

public boolean getTcpNoDelay()

getThreadPriority

public int getThreadPriority()

getUnlockTimeout

public int getUnlockTimeout()

getUseComet

public boolean getUseComet()

getUseSendfile

public boolean getUseSendfile()

getWorkerThread

protected AprEndpoint.Worker getWorkerThread()
Return a new worker thread, and block while to worker is available.

init

public void init()
Initialize the endpoint.

isPaused

public boolean isPaused()
Return the state of the endpoint.

Returns: true if the endpoint is paused, false otherwise

isRunning

public boolean isRunning()
Return the state of the endpoint.

Returns: true if the endpoint is running, false otherwise

isSSLEnabled

public boolean isSSLEnabled()

newWorkerThread

protected AprEndpoint.Worker newWorkerThread()
Create and return a new processor suitable for processing HTTP requests and returning the corresponding responses.

pause

public void pause()
Pause the endpoint, which will make it stop accepting new sockets.

processSocket

protected boolean processSocket(long socket)
Process given socket.

processSocket

protected boolean processSocket(long socket, SocketStatus status)
Process given socket for an event.

processSocketWithOptions

protected boolean processSocketWithOptions(long socket)
Process given socket.

recycleWorkerThread

protected void recycleWorkerThread(AprEndpoint.Worker workerThread)
Recycle the specified Processor so that it can be used again.

Parameters: workerThread The processor to be recycled

resume

public void resume()
Resume the endpoint, which will make it start accepting new sockets again.

setAcceptorThreadCount

public void setAcceptorThreadCount(int acceptorThreadCount)

setAddress

public void setAddress(InetAddress address)

setBacklog

public void setBacklog(int backlog)

setDaemon

public void setDaemon(boolean b)

setDeferAccept

public void setDeferAccept(boolean deferAccept)

setExecutor

public void setExecutor(Executor executor)

setHandler

public void setHandler(AprEndpoint.Handler handler)

setKeepAliveTimeout

public void setKeepAliveTimeout(int keepAliveTimeout)

setMaxThreads

public void setMaxThreads(int maxThreads)

setName

public void setName(String name)

setPollerSize

public void setPollerSize(int pollerSize)

setPollerThreadCount

public void setPollerThreadCount(int pollerThreadCount)

setPollTime

public void setPollTime(int pollTime)

setPort

public void setPort(int port)

setSendfileSize

public void setSendfileSize(int sendfileSize)

setSendfileThreadCount

public void setSendfileThreadCount(int sendfileThreadCount)

setSocketOptions

protected boolean setSocketOptions(long socket)
Process the specified connection.

setSoLinger

public void setSoLinger(int soLinger)

setSoTimeout

public void setSoTimeout(int soTimeout)

setSSLCACertificateFile

public void setSSLCACertificateFile(String SSLCACertificateFile)

setSSLCACertificatePath

public void setSSLCACertificatePath(String SSLCACertificatePath)

setSSLCARevocationFile

public void setSSLCARevocationFile(String SSLCARevocationFile)

setSSLCARevocationPath

public void setSSLCARevocationPath(String SSLCARevocationPath)

setSSLCertificateChainFile

public void setSSLCertificateChainFile(String SSLCertificateChainFile)

setSSLCertificateFile

public void setSSLCertificateFile(String SSLCertificateFile)

setSSLCertificateKeyFile

public void setSSLCertificateKeyFile(String SSLCertificateKeyFile)

setSSLCipherSuite

public void setSSLCipherSuite(String SSLCipherSuite)

setSSLEnabled

public void setSSLEnabled(boolean SSLEnabled)

setSSLPassword

public void setSSLPassword(String SSLPassword)

setSSLProtocol

public void setSSLProtocol(String SSLProtocol)

setSSLVerifyClient

public void setSSLVerifyClient(String SSLVerifyClient)

setSSLVerifyDepth

public void setSSLVerifyDepth(int SSLVerifyDepth)

setTcpNoDelay

public void setTcpNoDelay(boolean tcpNoDelay)

setThreadPriority

public void setThreadPriority(int threadPriority)

setUnlockTimeout

public void setUnlockTimeout(int unlockTimeout)

setUseComet

public void setUseComet(boolean useComet)

setUseSendfile

public void setUseSendfile(boolean useSendfile)

start

public void start()
Start the APR endpoint, creating acceptor, poller and sendfile threads.

stop

public void stop()
Stop the endpoint. This will cause all processing threads to stop.

unlockAccept

protected void unlockAccept()
Unlock the server socket accept using a bugus connection.
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.