Class SocketProperties
java.lang.Object
org.apache.tomcat.util.net.SocketProperties
Properties 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
FieldsModifier and TypeFieldDescriptionprotected intThe application read buffer size in bytes.protected intThe application write buffer size in bytes.protected intNioChannel pool size for the endpoint, this value is how many channels.protected intBuffer pool size in bytes to be cached.protected booleanEnable/disable direct buffers for the network buffers.protected booleanEnable/disable direct buffers for the network buffers for SSL.protected intEnable/disable poller event cache, this bounded cache stores PollerEvent objects to reduce GC for the pollerprotected BooleanOOBINLINE option.protected IntegerPerformance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.protected IntegerPerformance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.protected IntegerPerformance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used.protected intEnable/disable socket processor cache, this bounded cache stores SocketProcessor objects to reduce GC.protected IntegerSocket receive buffer size in bytes (SO_RCVBUF).protected BooleanSO_KEEPALIVE option.protected BooleanSO_LINGER option, paired with thesoLingerTimevalue.protected IntegerSO_LINGER option, paired with thesoLingerOnvalue.protected BooleanSO_REUSEADDR option.protected IntegerSO_TIMEOUT option. default is 20000.protected BooleanTCP_NO_DELAY option.protected longThe minimum frequency of the timeout interval to avoid excess load from the poller during high trafficprotected IntegerSocket send buffer size in bytes (SO_SNDBUF).protected intTimeout in milliseconds for an unlock to take place. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of SocketProperties with default values. -
Method Summary
Modifier and TypeMethodDescriptionintgetActualBufferPool(int bufferOverhead) Get the actual buffer pool size to use.intReturns the application read buffer size in bytes.intReturns the application write buffer size in bytes.intReturns the NioChannel pool size.intReturns the buffer pool size in bytes to be cached.booleanReturns whether direct buffers are used for network buffers.intReturns the direct buffer pool size.booleanReturns whether direct buffers are used for SSL network buffers.intReturns the poller event cache size.booleanReturns the OOBINLINE socket option value.intReturns the performance preference for bandwidth.intReturns the performance preference for connection time.intReturns the performance preference for latency.intReturns the socket processor cache size.intReturns the socket receive buffer size in bytes.booleanReturns the SO_KEEPALIVE socket option value.booleanReturns whether SO_LINGER is enabled.intReturns the SO_LINGER timeout value in seconds.booleanReturns the SO_REUSEADDR socket option value.intReturns the SO_TIMEOUT value in milliseconds.booleanReturns the TCP_NODELAY socket option value.longReturns the minimum frequency of the timeout interval in milliseconds.intReturns the socket send buffer size in bytes.intReturns 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(ServerSocket socket) Applies socket properties to the givenServerSocket.voidsetProperties(Socket socket) Applies socket properties to the givenSocket.voidApplies socket properties to the givenAsynchronousServerSocketChannel.voidApplies 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 Details
-
processorCache
protected int processorCacheEnable/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 eventCacheEnable/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 directBufferEnable/disable direct buffers for the network buffers. Default value is disabled. -
directSslBuffer
protected boolean directSslBufferEnable/disable direct buffers for the network buffers for SSL. Default value is disabled. -
rxBufSize
Socket receive buffer size in bytes (SO_RCVBUF). JVM default used if not set. -
txBufSize
Socket send buffer size in bytes (SO_SNDBUF). JVM default used if not set. -
appReadBufSize
protected int appReadBufSizeThe application read buffer size in bytes. Default value is 8192. -
appWriteBufSize
protected int appWriteBufSizeThe application write buffer size in bytes. Default value is 8192. -
bufferPool
protected int bufferPoolNioChannel 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 bufferPoolSizeBuffer 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
TCP_NO_DELAY option. JVM default used if not set. -
soKeepAlive
SO_KEEPALIVE option. JVM default used if not set. -
ooBInline
OOBINLINE option. JVM default used if not set. -
soReuseAddress
SO_REUSEADDR option. JVM default used if not set. -
soLingerOn
SO_LINGER option, paired with thesoLingerTimevalue. JVM defaults used unless both attributes are set. -
soLingerTime
SO_LINGER option, paired with thesoLingerOnvalue. JVM defaults used unless both attributes are set. -
soTimeout
SO_TIMEOUT option. default is 20000. -
performanceConnectionTime
Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used. -
performanceLatency
Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used. -
performanceBandwidth
Performance preferences according to setPerformancePreferences All three performance attributes must be set or the JVM defaults will be used. -
timeoutInterval
protected long timeoutIntervalThe minimum frequency of the timeout interval to avoid excess load from the poller during high traffic -
unlockTimeout
protected int unlockTimeoutTimeout in milliseconds for an unlock to take place.
-
-
Constructor Details
-
SocketProperties
public SocketProperties()Creates a new instance of SocketProperties with default values.
-
-
Method Details
-
setProperties
Applies socket properties to the givenSocket.- Parameters:
socket- the socket to configure- Throws:
SocketException- if a socket error occurs
-
setProperties
Applies socket properties to the givenServerSocket.- Parameters:
socket- the server socket to configure- Throws:
SocketException- if a socket error occurs
-
setProperties
Applies socket properties to the givenAsynchronousSocketChannel.- Parameters:
socket- the asynchronous socket channel to configure- Throws:
IOException- if an I/O error occurs
-
setProperties
Applies socket properties to the givenAsynchronousServerSocketChannel.- Parameters:
socket- the asynchronous server socket channel to configure- Throws:
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
-