org.apache.tomcat.util.net
Class AprEndpoint

java.lang.Object
  extended by org.apache.tomcat.util.net.AprEndpoint

public class AprEndpoint
extends java.lang.Object

APR endpoint, providing the following services:

Author:
Mladen Turk, Remy Maucherat

Nested Class Summary
protected  class AprEndpoint.Acceptor
          Server socket acceptor thread.
static interface AprEndpoint.Handler
          Bare bones interface used for socket processing.
 class AprEndpoint.Poller
          Poller class.
 class AprEndpoint.Sendfile
          Sendfile class.
static class AprEndpoint.SendfileData
          SendfileData class.
protected  class AprEndpoint.SocketEventProcessor
          This class is the equivalent of the Worker, but will simply use in an external Executor thread pool.
static class AprEndpoint.SocketInfo
          Socket list class, used to avoid using a possibly large amount of objects with very little actual use.
 class AprEndpoint.SocketList
          Socket list class, used to avoid using a possibly large amount of objects with very little actual use.
protected  class AprEndpoint.SocketProcessor
          This class is the equivalent of the Worker, but will simply use in an external Executor thread pool.
 class AprEndpoint.SocketTimeouts
          Socket list class, used to avoid using a possibly large amount of objects with very little actual use.
protected  class AprEndpoint.SocketWithOptionsProcessor
          This class is the equivalent of the Worker, but will simply use in an external Executor thread pool.
protected  class AprEndpoint.Worker
          Server processor class.
 class AprEndpoint.WorkerStack
           
 
Field Summary
protected  java.net.InetAddress address
          Address for the server socket.
protected  int backlog
          Allows the server developer to specify the backlog that should be used for server sockets.
static java.lang.String CERTIFICATE_KEY
          The Request attribute key for the client certificate chain.
static java.lang.String CIPHER_SUITE_KEY
          The Request attribute key for the cipher suite.
protected  int curThreads
          Current worker threads count.
protected  int curThreadsBusy
          Current worker threads busy count.
protected  boolean daemon
          The default is true - the created threads will be in daemon mode.
protected  boolean deferAccept
          Defer accept.
protected  AprEndpoint.Poller eventPoller
          The socket poller used for event support.
protected  java.util.concurrent.Executor executor
          External Executor based thread pool.
protected  AprEndpoint.Handler handler
          Handling of accepted sockets.
protected  boolean initialized
          Track the initialization state of the endpoint.
protected  int keepAliveTimeout
          Keep-Alive timeout.
static java.lang.String KEY_SIZE_KEY
          The Request attribute key for the key size.
protected  org.apache.tomcat.util.net.AprEndpoint.ListSock[] listsock
           
protected static org.jboss.logging.Logger log
           
protected  int maxThreads
          Maximum amount of worker threads.
protected  java.lang.String name
          Name of the thread pool, which will be used for naming child threads.
protected  boolean paused
          Will be set to true whenever the endpoint is paused.
protected  AprEndpoint.Poller poller
          The socket poller.
protected  int pollerSize
          Size of the socket poller.
protected  int pollTime
          Poll interval, in microseconds.
protected  int port
          Server socket port.
protected  boolean reverseConnection
          Reverse connection.
protected  long rootPool
          Root APR memory pool.
protected  boolean running
          Running state of the endpoint.
protected  AprEndpoint.Sendfile sendfile
          The static file sender.
protected  int sendfileSize
          Size of the sendfile (= concurrent files which can be served).
protected  int sequence
          Sequence number used to generate thread names.
protected  long serverAddress
          The server address.
protected  int serverAddressFamily
          The server address family.
protected  long serverSock
          Server socket "pointer".
protected  long serverSockPool
          APR memory pool for the server socket.
static java.lang.String SESSION_ID_KEY
          The Request attribute key for the session id.
protected static StringManager sm
           
protected  int soLinger
          Socket linger.
protected  int soTimeout
          Socket timeout.
protected  java.lang.String SSLCACertificateFile
          SSL CA certificate file.
protected  java.lang.String SSLCACertificatePath
          SSL CA certificate path.
protected  java.lang.String SSLCARevocationFile
          SSL CA revocation file.
protected  java.lang.String SSLCARevocationPath
          SSL CA revocation path.
protected  java.lang.String SSLCertificateChainFile
          SSL certificate chain file.
protected  java.lang.String SSLCertificateFile
          SSL certificate file.
protected  java.lang.String SSLCertificateKeyFile
          SSL certificate key file.
protected  java.lang.String SSLCipherSuite
          SSL cipher suite.
protected  long sslContext
          SSL context.
protected  boolean SSLEnabled
          SSL engine.
protected  java.lang.String SSLPassword
          SSL password (if a cert is encrypted, and no password has been provided, a callback will ask for a password).
protected  java.lang.String SSLProtocol
          SSL protocols.
protected  java.lang.String SSLVerifyClient
          SSL verify client.
protected  int SSLVerifyDepth
          SSL verify depth.
protected  boolean tcpNoDelay
          Socket TCP no delay.
protected  int threadPriority
          Priority of the acceptor and poller threads.
protected  boolean useSendfile
          Use sendfile for sending static files.
protected  AprEndpoint.WorkerStack workers
          Available workers.
 
Constructor Summary
AprEndpoint()
           
 
Method Summary
protected  long allocatePoller(int size, long pool, int timeout)
          Allocate a new poller of the specified size.
protected  AprEndpoint.Worker createWorkerThread()
          Create (or allocate) and return an available processor for use in processing a specific HTTP request, if possible.
 void destroy()
          Deallocate APR memory pools, and close server socket.
 java.net.InetAddress getAddress()
           
 int getBacklog()
           
 int getCurrentThreadCount()
          Return the amount of threads that are managed by the pool.
 int getCurrentThreadsBusy()
          Return the amount of threads currently busy.
 boolean getDaemon()
           
 boolean getDeferAccept()
           
 AprEndpoint.Poller getEventPoller()
           
 java.util.concurrent.Executor getExecutor()
           
 AprEndpoint.Handler getHandler()
           
 int getKeepAliveCount()
          Number of keepalive sockets.
 int getKeepAliveTimeout()
           
 int getMaxThreads()
           
 java.lang.String getName()
           
 AprEndpoint.Poller getPoller()
           
 int getPollerSize()
           
 int getPollTime()
           
 int getPort()
           
 AprEndpoint.Sendfile getSendfile()
           
 int getSendfileCount()
          Number of sendfile sockets.
 int getSendfileSize()
           
protected  int getSequence()
          Get a sequence number used for thread naming.
 int getSoLinger()
           
 int getSoTimeout()
           
 java.lang.String getSSLCACertificateFile()
           
 java.lang.String getSSLCACertificatePath()
           
 java.lang.String getSSLCARevocationFile()
           
 java.lang.String getSSLCARevocationPath()
           
 java.lang.String getSSLCertificateChainFile()
           
 java.lang.String getSSLCertificateFile()
           
 java.lang.String getSSLCertificateKeyFile()
           
 java.lang.String getSSLCipherSuite()
           
 java.lang.String getSSLPassword()
           
 java.lang.String getSSLProtocol()
           
 java.lang.String getSSLVerifyClient()
           
 int getSSLVerifyDepth()
           
 boolean getTcpNoDelay()
           
 int getThreadPriority()
           
 boolean getUseSendfile()
           
protected  AprEndpoint.Worker getWorkerThread()
          Return a new worker thread, and block while to worker is available.
 void init()
          Initialize the endpoint.
 boolean isPaused()
          Return the state of the endpoint.
 boolean isReverseConnection()
           
 boolean isRunning()
          Return the state of the endpoint.
 boolean isSSLEnabled()
           
protected  AprEndpoint.Worker newWorkerThread()
          Create and return a new processor suitable for processing HTTP requests and returning the corresponding responses.
 void pause()
          Pause the endpoint, which will make it stop accepting new sockets.
protected  boolean processSocket(long socket)
          Process given socket.
protected  boolean processSocket(long socket, SocketStatus status)
          Process given socket for an event.
protected  boolean processSocketWithOptions(long socket)
          Process given socket.
protected  void recycleWorkerThread(AprEndpoint.Worker workerThread)
          Recycle the specified Processor so that it can be used again.
 void resume()
          Resume the endpoint, which will make it start accepting new sockets again.
 void setAddress(java.net.InetAddress address)
           
 void setBacklog(int backlog)
           
 void setDaemon(boolean b)
           
 void setDeferAccept(boolean deferAccept)
           
 void setExecutor(java.util.concurrent.Executor executor)
           
 void setHandler(AprEndpoint.Handler handler)
           
 void setKeepAliveTimeout(int keepAliveTimeout)
           
 void setMaxThreads(int maxThreads)
           
 void setName(java.lang.String name)
           
 void setPollerSize(int pollerSize)
           
 void setPollTime(int pollTime)
           
 void setPort(int port)
           
 void setReverseConnection(boolean reverseConnection)
           
 void setSendfileSize(int sendfileSize)
           
protected  boolean setSocketOptions(long socket)
          Process the specified connection.
 void setSoLinger(int soLinger)
           
 void setSoTimeout(int soTimeout)
           
 void setSSLCACertificateFile(java.lang.String SSLCACertificateFile)
           
 void setSSLCACertificatePath(java.lang.String SSLCACertificatePath)
           
 void setSSLCARevocationFile(java.lang.String SSLCARevocationFile)
           
 void setSSLCARevocationPath(java.lang.String SSLCARevocationPath)
           
 void setSSLCertificateChainFile(java.lang.String SSLCertificateChainFile)
           
 void setSSLCertificateFile(java.lang.String SSLCertificateFile)
           
 void setSSLCertificateKeyFile(java.lang.String SSLCertificateKeyFile)
           
 void setSSLCipherSuite(java.lang.String SSLCipherSuite)
           
 void setSSLEnabled(boolean SSLEnabled)
           
 void setSSLPassword(java.lang.String SSLPassword)
           
 void setSSLProtocol(java.lang.String SSLProtocol)
           
 void setSSLVerifyClient(java.lang.String SSLVerifyClient)
           
 void setSSLVerifyDepth(int SSLVerifyDepth)
           
 void setTcpNoDelay(boolean tcpNoDelay)
           
 void setThreadPriority(int threadPriority)
           
 void setUseSendfile(boolean useSendfile)
           
 void start()
          Start the APR endpoint, creating acceptor, poller and sendfile threads.
 void stop()
          Stop the endpoint.
protected  void unlockAccept()
          Unlock the server socket accept using a bogus connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.jboss.logging.Logger log

sm

protected static StringManager sm

CIPHER_SUITE_KEY

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

See Also:
Constant Field Values

KEY_SIZE_KEY

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

See Also:
Constant Field Values

CERTIFICATE_KEY

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

See Also:
Constant Field Values

SESSION_ID_KEY

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

See Also:
Constant Field Values

workers

protected AprEndpoint.WorkerStack workers
Available workers.


running

protected volatile boolean running
Running state of the endpoint.


paused

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


initialized

protected boolean initialized
Track the initialization state of the endpoint.


curThreadsBusy

protected int curThreadsBusy
Current worker threads busy count.


curThreads

protected int curThreads
Current worker threads count.


sequence

protected int sequence
Sequence number used to generate thread names.


rootPool

protected long rootPool
Root APR memory pool.


serverSock

protected long serverSock
Server socket "pointer".


serverSockPool

protected long serverSockPool
APR memory pool for the server socket.


sslContext

protected long sslContext
SSL context.


executor

protected java.util.concurrent.Executor executor
External Executor based thread pool.


maxThreads

protected int maxThreads
Maximum amount of worker threads.


threadPriority

protected int threadPriority
Priority of the acceptor and poller threads.


pollerSize

protected int pollerSize
Size of the socket poller.


sendfileSize

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


port

protected int port
Server socket port.


address

protected java.net.InetAddress address
Address for the server socket.


handler

protected AprEndpoint.Handler handler
Handling of accepted sockets.


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.


tcpNoDelay

protected boolean tcpNoDelay
Socket TCP no delay.


soLinger

protected int soLinger
Socket linger.


soTimeout

protected int soTimeout
Socket timeout.


deferAccept

protected boolean deferAccept
Defer accept.


keepAliveTimeout

protected int keepAliveTimeout
Keep-Alive timeout.


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.


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.


name

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


useSendfile

protected boolean useSendfile
Use sendfile for sending static files.


poller

protected AprEndpoint.Poller poller
The socket poller.


eventPoller

protected AprEndpoint.Poller eventPoller
The socket poller used for event support.


sendfile

protected AprEndpoint.Sendfile sendfile
The static file sender.


serverAddress

protected long serverAddress
The server address.


serverAddressFamily

protected int serverAddressFamily
The server address family.


reverseConnection

protected boolean reverseConnection
Reverse connection. In this proxied mode, the endpoint will not use a server socket, but will connect itself to the front end server.


listsock

protected org.apache.tomcat.util.net.AprEndpoint.ListSock[] listsock

SSLEnabled

protected boolean SSLEnabled
SSL engine.


SSLProtocol

protected java.lang.String SSLProtocol
SSL protocols.


SSLPassword

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


SSLCipherSuite

protected java.lang.String SSLCipherSuite
SSL cipher suite.


SSLCertificateFile

protected java.lang.String SSLCertificateFile
SSL certificate file.


SSLCertificateKeyFile

protected java.lang.String SSLCertificateKeyFile
SSL certificate key file.


SSLCertificateChainFile

protected java.lang.String SSLCertificateChainFile
SSL certificate chain file.


SSLCACertificatePath

protected java.lang.String SSLCACertificatePath
SSL CA certificate path.


SSLCACertificateFile

protected java.lang.String SSLCACertificateFile
SSL CA certificate file.


SSLCARevocationPath

protected java.lang.String SSLCARevocationPath
SSL CA revocation path.


SSLCARevocationFile

protected java.lang.String SSLCARevocationFile
SSL CA revocation file.


SSLVerifyClient

protected java.lang.String SSLVerifyClient
SSL verify client.


SSLVerifyDepth

protected int SSLVerifyDepth
SSL verify depth.

Constructor Detail

AprEndpoint

public AprEndpoint()
Method Detail

setExecutor

public void setExecutor(java.util.concurrent.Executor executor)

getExecutor

public java.util.concurrent.Executor getExecutor()

setMaxThreads

public void setMaxThreads(int maxThreads)

getMaxThreads

public int getMaxThreads()

setThreadPriority

public void setThreadPriority(int threadPriority)

getThreadPriority

public int getThreadPriority()

setPollerSize

public void setPollerSize(int pollerSize)

getPollerSize

public int getPollerSize()

setSendfileSize

public void setSendfileSize(int sendfileSize)

getSendfileSize

public int getSendfileSize()

getPort

public int getPort()

setPort

public void setPort(int port)

getAddress

public java.net.InetAddress getAddress()

setAddress

public void setAddress(java.net.InetAddress address)

setHandler

public void setHandler(AprEndpoint.Handler handler)

getHandler

public AprEndpoint.Handler getHandler()

setBacklog

public void setBacklog(int backlog)

getBacklog

public int getBacklog()

getTcpNoDelay

public boolean getTcpNoDelay()

setTcpNoDelay

public void setTcpNoDelay(boolean tcpNoDelay)

getSoLinger

public int getSoLinger()

setSoLinger

public void setSoLinger(int soLinger)

getSoTimeout

public int getSoTimeout()

setSoTimeout

public void setSoTimeout(int soTimeout)

setDeferAccept

public void setDeferAccept(boolean deferAccept)

getDeferAccept

public boolean getDeferAccept()

getKeepAliveTimeout

public int getKeepAliveTimeout()

setKeepAliveTimeout

public void setKeepAliveTimeout(int keepAliveTimeout)

getPollTime

public int getPollTime()

setPollTime

public void setPollTime(int pollTime)

setDaemon

public void setDaemon(boolean b)

getDaemon

public boolean getDaemon()

setName

public void setName(java.lang.String name)

getName

public java.lang.String getName()

setUseSendfile

public void setUseSendfile(boolean useSendfile)

getUseSendfile

public boolean getUseSendfile()

getPoller

public AprEndpoint.Poller getPoller()

getEventPoller

public AprEndpoint.Poller getEventPoller()

getSendfile

public AprEndpoint.Sendfile getSendfile()

isReverseConnection

public boolean isReverseConnection()

setReverseConnection

public void setReverseConnection(boolean reverseConnection)

isSSLEnabled

public boolean isSSLEnabled()

setSSLEnabled

public void setSSLEnabled(boolean SSLEnabled)

getSSLProtocol

public java.lang.String getSSLProtocol()

setSSLProtocol

public void setSSLProtocol(java.lang.String SSLProtocol)

getSSLPassword

public java.lang.String getSSLPassword()

setSSLPassword

public void setSSLPassword(java.lang.String SSLPassword)

getSSLCipherSuite

public java.lang.String getSSLCipherSuite()

setSSLCipherSuite

public void setSSLCipherSuite(java.lang.String SSLCipherSuite)

getSSLCertificateFile

public java.lang.String getSSLCertificateFile()

setSSLCertificateFile

public void setSSLCertificateFile(java.lang.String SSLCertificateFile)

getSSLCertificateKeyFile

public java.lang.String getSSLCertificateKeyFile()

setSSLCertificateKeyFile

public void setSSLCertificateKeyFile(java.lang.String SSLCertificateKeyFile)

getSSLCertificateChainFile

public java.lang.String getSSLCertificateChainFile()

setSSLCertificateChainFile

public void setSSLCertificateChainFile(java.lang.String SSLCertificateChainFile)

getSSLCACertificatePath

public java.lang.String getSSLCACertificatePath()

setSSLCACertificatePath

public void setSSLCACertificatePath(java.lang.String SSLCACertificatePath)

getSSLCACertificateFile

public java.lang.String getSSLCACertificateFile()

setSSLCACertificateFile

public void setSSLCACertificateFile(java.lang.String SSLCACertificateFile)

getSSLCARevocationPath

public java.lang.String getSSLCARevocationPath()

setSSLCARevocationPath

public void setSSLCARevocationPath(java.lang.String SSLCARevocationPath)

getSSLCARevocationFile

public java.lang.String getSSLCARevocationFile()

setSSLCARevocationFile

public void setSSLCARevocationFile(java.lang.String SSLCARevocationFile)

getSSLVerifyClient

public java.lang.String getSSLVerifyClient()

setSSLVerifyClient

public void setSSLVerifyClient(java.lang.String SSLVerifyClient)

getSSLVerifyDepth

public int getSSLVerifyDepth()

setSSLVerifyDepth

public void setSSLVerifyDepth(int SSLVerifyDepth)

getKeepAliveCount

public int getKeepAliveCount()
Number of keepalive sockets.


getSendfileCount

public int getSendfileCount()
Number of sendfile sockets.


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 currently busy.

Returns:
the amount of threads currently busy

isRunning

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

Returns:
true if the endpoint is running, false otherwise

isPaused

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

Returns:
true if the endpoint is paused, false otherwise

init

public void init()
          throws java.lang.Exception
Initialize the endpoint.

Throws:
java.lang.Exception

start

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

Throws:
java.lang.Exception

pause

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


resume

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


stop

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


destroy

public void destroy()
             throws java.lang.Exception
Deallocate APR memory pools, and close server socket.

Throws:
java.lang.Exception

getSequence

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


unlockAccept

protected void unlockAccept()
Unlock the server socket accept using a bogus connection.


setSocketOptions

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


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.


newWorkerThread

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


getWorkerThread

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


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

allocatePoller

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


processSocketWithOptions

protected boolean processSocketWithOptions(long socket)
Process given socket.


processSocket

protected boolean processSocket(long socket)
Process given socket.


processSocket

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



Copyright © 2000-2009 Apache Software Foundation. All Rights Reserved.