Package org.apache.tomcat.util.net
Class SocketProperties
- java.lang.Object
-
- org.apache.tomcat.util.net.SocketProperties
-
public class SocketProperties extends java.lang.ObjectProperties that can be set in the <Connector> element in server.xml. All properties are prefixed with "socket." and are currently only working for the Nio connector
-
-
Field Summary
Fields Modifier and Type Field Description protected intappReadBufSizeThe application read buffer size in bytes.protected intappWriteBufSizeThe application write buffer size in bytes.protected intbufferPoolNioChannel pool size for the endpoint, this value is how many channels.protected intbufferPoolSizeBuffer pool size in bytes to be cached.protected booleandirectBufferEnable/disable direct buffers for the network buffers.protected booleandirectSslBufferEnable/disable direct buffers for the network buffers for SSL.protected inteventCacheEnable/disable poller event cache, this bounded cache stores PollerEvent objects to reduce GC for the pollerprotected java.lang.BooleanooBInlineOOBINLINE option.protected java.lang.IntegerperformanceBandwidthPerformance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.protected java.lang.IntegerperformanceConnectionTimePerformance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.protected java.lang.IntegerperformanceLatencyPerformance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.protected intprocessorCacheEnable/disable socket processor cache, this bounded cache stores SocketProcessor objects to reduce GC.protected java.lang.IntegerrxBufSizeSocket receive buffer size in bytes (SO_RCVBUF).protected java.lang.BooleansoKeepAliveSO_KEEPALIVE option.protected java.lang.BooleansoLingerOnSO_LINGER option, paired with thesoLingerTimevalue.protected java.lang.IntegersoLingerTimeSO_LINGER option, paired with thesoLingerOnvalue.protected java.lang.BooleansoReuseAddressSO_REUSEADDR option.protected java.lang.IntegersoTimeoutSO_TIMEOUT option. default is 20000.protected java.lang.BooleantcpNoDelayTCP_NO_DELAY option.protected longtimeoutIntervalThe minimum frequency of the timeout interval to avoid excess load from the poller during high trafficprotected java.lang.IntegertxBufSizeSocket send buffer size in bytes (SO_SNDBUF).protected intunlockTimeoutTimeout in milliseconds for an unlock to take place.
-
Constructor Summary
Constructors Constructor Description SocketProperties()Creates a new instance of SocketProperties with default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetActualBufferPool(int bufferOverhead)Get the actual buffer pool size to use.intgetAppReadBufSize()Returns the application read buffer size in bytes.intgetAppWriteBufSize()Returns the application write buffer size in bytes.intgetBufferPool()Returns the NioChannel pool size.intgetBufferPoolSize()Returns the buffer pool size in bytes to be cached.booleangetDirectBuffer()Returns whether direct buffers are used for network buffers.intgetDirectBufferPool()Returns the direct buffer pool size.booleangetDirectSslBuffer()Returns whether direct buffers are used for SSL network buffers.intgetEventCache()Returns the poller event cache size.booleangetOoBInline()Returns the OOBINLINE socket option value.intgetPerformanceBandwidth()Returns the performance preference for bandwidth.intgetPerformanceConnectionTime()Returns the performance preference for connection time.intgetPerformanceLatency()Returns the performance preference for latency.intgetProcessorCache()Returns the socket processor cache size.intgetRxBufSize()Returns the socket receive buffer size in bytes.booleangetSoKeepAlive()Returns the SO_KEEPALIVE socket option value.booleangetSoLingerOn()Returns whether SO_LINGER is enabled.intgetSoLingerTime()Returns the SO_LINGER timeout value in seconds.booleangetSoReuseAddress()Returns the SO_REUSEADDR socket option value.intgetSoTimeout()Returns the SO_TIMEOUT value in milliseconds.booleangetTcpNoDelay()Returns the TCP_NODELAY socket option value.longgetTimeoutInterval()Returns the minimum frequency of the timeout interval in milliseconds.intgetTxBufSize()Returns the socket send buffer size in bytes.intgetUnlockTimeout()Returns the unlock timeout in milliseconds.voidsetAppReadBufSize(int appReadBufSize)Sets the application read buffer size in bytes.voidsetAppWriteBufSize(int appWriteBufSize)Sets the application write buffer size in bytes.voidsetBufferPool(int bufferPool)Sets the NioChannel pool size.voidsetBufferPoolSize(int bufferPoolSize)Sets the buffer pool size in bytes to be cached.voidsetDirectBuffer(boolean directBuffer)Sets whether direct buffers are used for network buffers.voidsetDirectBufferPool(int directBufferPool)Sets the direct buffer pool size.voidsetDirectSslBuffer(boolean directSslBuffer)Sets whether direct buffers are used for SSL network buffers.voidsetEventCache(int eventCache)Sets the poller event cache size.voidsetOoBInline(boolean ooBInline)Sets the OOBINLINE socket option.voidsetPerformanceBandwidth(int performanceBandwidth)Sets the performance preference for bandwidth.voidsetPerformanceConnectionTime(int performanceConnectionTime)Sets the performance preference for connection time.voidsetPerformanceLatency(int performanceLatency)Sets the performance preference for latency.voidsetProcessorCache(int processorCache)Sets the socket processor cache size.voidsetProperties(java.net.ServerSocket socket)Applies socket properties to the givenServerSocket.voidsetProperties(java.net.Socket socket)Applies socket properties to the givenSocket.voidsetProperties(java.nio.channels.AsynchronousServerSocketChannel socket)Applies socket properties to the givenAsynchronousServerSocketChannel.voidsetProperties(java.nio.channels.AsynchronousSocketChannel socket)Applies socket properties to the givenAsynchronousSocketChannel.voidsetRxBufSize(int rxBufSize)Sets the socket receive buffer size in bytes.voidsetSoKeepAlive(boolean soKeepAlive)Sets the SO_KEEPALIVE socket option.voidsetSoLingerOn(boolean soLingerOn)Sets whether SO_LINGER is enabled.voidsetSoLingerTime(int soLingerTime)Sets the SO_LINGER timeout value in seconds.voidsetSoReuseAddress(boolean soReuseAddress)Sets the SO_REUSEADDR socket option.voidsetSoTimeout(int soTimeout)Sets the SO_TIMEOUT value in milliseconds.voidsetTcpNoDelay(boolean tcpNoDelay)Sets the TCP_NODELAY socket option.voidsetTimeoutInterval(long timeoutInterval)Sets the minimum frequency of the timeout interval in milliseconds.voidsetTxBufSize(int txBufSize)Sets the socket send buffer size in bytes.voidsetUnlockTimeout(int unlockTimeout)Sets the unlock timeout in milliseconds.
-
-
-
Field Detail
-
processorCache
protected int processorCache
Enable/disable socket processor cache, this bounded cache stores SocketProcessor objects to reduce GC.Default is 0
-1 is unlimited
0 is disabled
-
eventCache
protected int eventCache
Enable/disable poller event cache, this bounded cache stores PollerEvent objects to reduce GC for the pollerDefault is 0
-1 is unlimited
0 is disabled
>0 the max number of objects to keep in cache.
-
directBuffer
protected boolean directBuffer
Enable/disable direct buffers for the network buffers. Default value is disabled.
-
directSslBuffer
protected boolean directSslBuffer
Enable/disable direct buffers for the network buffers for SSL. Default value is disabled.
-
rxBufSize
protected java.lang.Integer rxBufSize
Socket receive buffer size in bytes (SO_RCVBUF). JVM default used if not set.
-
txBufSize
protected java.lang.Integer txBufSize
Socket send buffer size in bytes (SO_SNDBUF). JVM default used if not set.
-
appReadBufSize
protected int appReadBufSize
The application read buffer size in bytes. Default value is 8192.
-
appWriteBufSize
protected int appWriteBufSize
The application write buffer size in bytes. Default value is 8192.
-
bufferPool
protected int bufferPool
NioChannel pool size for the endpoint, this value is how many channels.0 means no cache
-1 means unlimited cached
-2 means bufferPoolSize will be used
Default value is -2
-
bufferPoolSize
protected int bufferPoolSize
Buffer pool size in bytes to be cached.-1 means unlimited
0 means no cache
Default value is based on the max memory reported by the JVM, if less than 1GB, then 0, else the value divided by 32. This value will then be used to compute bufferPool if its value is -2
-
tcpNoDelay
protected java.lang.Boolean tcpNoDelay
TCP_NO_DELAY option. JVM default used if not set.
-
soKeepAlive
protected java.lang.Boolean soKeepAlive
SO_KEEPALIVE option. JVM default used if not set.
-
ooBInline
protected java.lang.Boolean ooBInline
OOBINLINE option. JVM default used if not set.
-
soReuseAddress
protected java.lang.Boolean soReuseAddress
SO_REUSEADDR option. JVM default used if not set.
-
soLingerOn
protected java.lang.Boolean soLingerOn
SO_LINGER option, paired with thesoLingerTimevalue. JVM defaults used unless both attributes are set.
-
soLingerTime
protected java.lang.Integer soLingerTime
SO_LINGER option, paired with thesoLingerOnvalue. JVM defaults used unless both attributes are set.
-
soTimeout
protected java.lang.Integer soTimeout
SO_TIMEOUT option. default is 20000.
-
performanceConnectionTime
protected java.lang.Integer performanceConnectionTime
Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.
-
performanceLatency
protected java.lang.Integer performanceLatency
Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.
-
performanceBandwidth
protected java.lang.Integer performanceBandwidth
Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.
-
timeoutInterval
protected long timeoutInterval
The minimum frequency of the timeout interval to avoid excess load from the poller during high traffic
-
unlockTimeout
protected int unlockTimeout
Timeout in milliseconds for an unlock to take place.
-
-
Method Detail
-
setProperties
public void setProperties(java.net.Socket socket) throws java.net.SocketExceptionApplies socket properties to the givenSocket.- Parameters:
socket- the socket to configure- Throws:
java.net.SocketException- if a socket error occurs
-
setProperties
public void setProperties(java.net.ServerSocket socket) throws java.net.SocketExceptionApplies socket properties to the givenServerSocket.- Parameters:
socket- the server socket to configure- Throws:
java.net.SocketException- if a socket error occurs
-
setProperties
public void setProperties(java.nio.channels.AsynchronousSocketChannel socket) throws java.io.IOExceptionApplies socket properties to the givenAsynchronousSocketChannel.- Parameters:
socket- the asynchronous socket channel to configure- Throws:
java.io.IOException- if an I/O error occurs
-
setProperties
public void setProperties(java.nio.channels.AsynchronousServerSocketChannel socket) throws java.io.IOExceptionApplies socket properties to the givenAsynchronousServerSocketChannel.- Parameters:
socket- the asynchronous server socket channel to configure- Throws:
java.io.IOException- if an I/O error occurs
-
getDirectBuffer
public boolean getDirectBuffer()
Returns whether direct buffers are used for network buffers.- Returns:
trueif direct buffers are enabled
-
getDirectSslBuffer
public boolean getDirectSslBuffer()
Returns whether direct buffers are used for SSL network buffers.- Returns:
trueif direct SSL buffers are enabled
-
getOoBInline
public boolean getOoBInline()
Returns the OOBINLINE socket option value.- Returns:
- the OOBINLINE value
-
getPerformanceBandwidth
public int getPerformanceBandwidth()
Returns the performance preference for bandwidth.- Returns:
- the bandwidth preference value
-
getPerformanceConnectionTime
public int getPerformanceConnectionTime()
Returns the performance preference for connection time.- Returns:
- the connection time preference value
-
getPerformanceLatency
public int getPerformanceLatency()
Returns the performance preference for latency.- Returns:
- the latency preference value
-
getRxBufSize
public int getRxBufSize()
Returns the socket receive buffer size in bytes.- Returns:
- the receive buffer size
-
getSoKeepAlive
public boolean getSoKeepAlive()
Returns the SO_KEEPALIVE socket option value.- Returns:
- the keep-alive value
-
getSoLingerOn
public boolean getSoLingerOn()
Returns whether SO_LINGER is enabled.- Returns:
trueif SO_LINGER is enabled
-
getSoLingerTime
public int getSoLingerTime()
Returns the SO_LINGER timeout value in seconds.- Returns:
- the linger timeout value
-
getSoReuseAddress
public boolean getSoReuseAddress()
Returns the SO_REUSEADDR socket option value.- Returns:
- the reuse address value
-
getSoTimeout
public int getSoTimeout()
Returns the SO_TIMEOUT value in milliseconds.- Returns:
- the socket timeout value
-
getTcpNoDelay
public boolean getTcpNoDelay()
Returns the TCP_NODELAY socket option value.- Returns:
- the TCP no delay value
-
getTxBufSize
public int getTxBufSize()
Returns the socket send buffer size in bytes.- Returns:
- the send buffer size
-
getBufferPool
public int getBufferPool()
Returns the NioChannel pool size.- Returns:
- the buffer pool size
-
getBufferPoolSize
public int getBufferPoolSize()
Returns the buffer pool size in bytes to be cached.- Returns:
- the buffer pool byte size
-
getEventCache
public int getEventCache()
Returns the poller event cache size.- Returns:
- the event cache size
-
getAppReadBufSize
public int getAppReadBufSize()
Returns the application read buffer size in bytes.- Returns:
- the application read buffer size
-
getAppWriteBufSize
public int getAppWriteBufSize()
Returns the application write buffer size in bytes.- Returns:
- the application write buffer size
-
getProcessorCache
public int getProcessorCache()
Returns the socket processor cache size.- Returns:
- the processor cache size
-
getTimeoutInterval
public long getTimeoutInterval()
Returns the minimum frequency of the timeout interval in milliseconds.- Returns:
- the timeout interval
-
getDirectBufferPool
public int getDirectBufferPool()
Returns the direct buffer pool size.- Returns:
- the direct buffer pool size
-
setPerformanceConnectionTime
public void setPerformanceConnectionTime(int performanceConnectionTime)
Sets the performance preference for connection time.- Parameters:
performanceConnectionTime- the connection time preference value
-
setTxBufSize
public void setTxBufSize(int txBufSize)
Sets the socket send buffer size in bytes.- Parameters:
txBufSize- the send buffer size
-
setTcpNoDelay
public void setTcpNoDelay(boolean tcpNoDelay)
Sets the TCP_NODELAY socket option.- Parameters:
tcpNoDelay- the TCP no delay value
-
setSoTimeout
public void setSoTimeout(int soTimeout)
Sets the SO_TIMEOUT value in milliseconds.- Parameters:
soTimeout- the socket timeout value
-
setSoReuseAddress
public void setSoReuseAddress(boolean soReuseAddress)
Sets the SO_REUSEADDR socket option.- Parameters:
soReuseAddress- the reuse address value
-
setSoLingerTime
public void setSoLingerTime(int soLingerTime)
Sets the SO_LINGER timeout value in seconds.- Parameters:
soLingerTime- the linger timeout value
-
setSoKeepAlive
public void setSoKeepAlive(boolean soKeepAlive)
Sets the SO_KEEPALIVE socket option.- Parameters:
soKeepAlive- the keep-alive value
-
setRxBufSize
public void setRxBufSize(int rxBufSize)
Sets the socket receive buffer size in bytes.- Parameters:
rxBufSize- the receive buffer size
-
setPerformanceLatency
public void setPerformanceLatency(int performanceLatency)
Sets the performance preference for latency.- Parameters:
performanceLatency- the latency preference value
-
setPerformanceBandwidth
public void setPerformanceBandwidth(int performanceBandwidth)
Sets the performance preference for bandwidth.- Parameters:
performanceBandwidth- the bandwidth preference value
-
setOoBInline
public void setOoBInline(boolean ooBInline)
Sets the OOBINLINE socket option.- Parameters:
ooBInline- the OOB inline value
-
setDirectBuffer
public void setDirectBuffer(boolean directBuffer)
Sets whether direct buffers are used for network buffers.- Parameters:
directBuffer-trueto enable direct buffers
-
setDirectSslBuffer
public void setDirectSslBuffer(boolean directSslBuffer)
Sets whether direct buffers are used for SSL network buffers.- Parameters:
directSslBuffer-trueto enable direct SSL buffers
-
setSoLingerOn
public void setSoLingerOn(boolean soLingerOn)
Sets whether SO_LINGER is enabled.- Parameters:
soLingerOn-trueto enable SO_LINGER
-
setBufferPool
public void setBufferPool(int bufferPool)
Sets the NioChannel pool size.- Parameters:
bufferPool- the buffer pool size
-
setBufferPoolSize
public void setBufferPoolSize(int bufferPoolSize)
Sets the buffer pool size in bytes to be cached.- Parameters:
bufferPoolSize- the buffer pool byte size
-
setEventCache
public void setEventCache(int eventCache)
Sets the poller event cache size.- Parameters:
eventCache- the event cache size
-
setAppReadBufSize
public void setAppReadBufSize(int appReadBufSize)
Sets the application read buffer size in bytes.- Parameters:
appReadBufSize- the application read buffer size
-
setAppWriteBufSize
public void setAppWriteBufSize(int appWriteBufSize)
Sets the application write buffer size in bytes.- Parameters:
appWriteBufSize- the application write buffer size
-
setProcessorCache
public void setProcessorCache(int processorCache)
Sets the socket processor cache size.- Parameters:
processorCache- the processor cache size
-
setTimeoutInterval
public void setTimeoutInterval(long timeoutInterval)
Sets the minimum frequency of the timeout interval in milliseconds.- Parameters:
timeoutInterval- the timeout interval
-
setDirectBufferPool
public void setDirectBufferPool(int directBufferPool)
Sets the direct buffer pool size.- Parameters:
directBufferPool- the direct buffer pool size
-
getUnlockTimeout
public int getUnlockTimeout()
Returns the unlock timeout in milliseconds.- Returns:
- the unlock timeout
-
setUnlockTimeout
public void setUnlockTimeout(int unlockTimeout)
Sets the unlock timeout in milliseconds.- Parameters:
unlockTimeout- the unlock timeout value (must be positive)
-
getActualBufferPool
public int getActualBufferPool(int bufferOverhead)
Get the actual buffer pool size to use.- Parameters:
bufferOverhead- When TLS is enabled, additional network buffers are needed and will be added to the application buffer size- Returns:
- the actual buffer pool size that will be used
-
-