public class DefaultSessionConfig extends Object implements ISessionConfig
Constructor and Description |
---|
DefaultSessionConfig() |
Modifier and Type | Method and Description |
---|---|
ICodecExecutor |
createCodecExecutor()
Creates a new codec executor that will be responsible for decoding and
encoding data read/received and written/send in the associated session.
|
SSLEngine |
createSSLEngine(boolean clientMode)
Creates a new SSLEngine for the SSL/DTLS session.
|
SSLEngine |
createSSLEngine(SocketAddress remoteAddress,
boolean clientMode)
Creates a new SSLEngine for the SSL/DTLS session with known remote peer.
|
long |
getDatagramServerSessionNoReopenPeriod()
Determines how long the
DatagramServerHandler should block re-opening of a new session for the
remote peer which session has just been closed. |
EndingAction |
getEndingAction()
Gets the action that should be performed by the selector
loop after ending of the associated session.
|
long |
getEngineHandshakeTimeout()
Determines how long the SNF4J framework should wait for completion of the
handshake phase for engine-driven sessions.
|
int |
getMaxInBufferCapacity()
Gets the maximum capacity for the session's input buffer.
|
int |
getMaxSSLApplicationBufferSizeRatio()
Gets the ratio that is used to calculate the maximum size of the SSL
application buffers.
|
int |
getMaxSSLNetworkBufferSizeRatio()
Gets the ratio that is used to calculate the maximum size of the SSL
network buffers.
|
int |
getMaxWriteSpinCount()
Returns the maximum loop count for write operations performed by the selector
loop before returning control to the NIO selector or to other channel ready
for I/O operations.
|
int |
getMinInBufferCapacity()
Gets the minimum capacity for the session's input buffer.
|
int |
getMinOutBufferCapacity()
Gets the minimum capacity for the session's output buffer.
|
long |
getThroughputCalculationInterval()
Gets the interval in milliseconds between each throughput calculation.
|
boolean |
ignorePossiblyIncompleteDatagrams()
Determines if possibly incomplete datagrams should be ignored.
|
boolean |
optimizeDataCopying()
Determines if the processing of data should be optimized to reduce data
copying between byte buffers.
|
DefaultSessionConfig |
setDatagramServerSessionNoReopenPeriod(long period)
Configures how long the
DatagramServerHandler should block re-opening of a new session for the
remote peer which session has just been closed. |
DefaultSessionConfig |
setEndingAction(EndingAction action)
Sets an action that should be performed by the selector loop after ending of
the associated session.
|
DefaultSessionConfig |
setEngineHandshakeTimeout(long timeout)
Configures how long the SNF4J framework should wait for completion of the
handshake phase for engine-driven sessions.
|
DefaultSessionConfig |
setIgnorePossiblyIncompleteDatagrams(boolean ignore)
Configures the behavior after receiving possibly incomplete datagrams.
|
DefaultSessionConfig |
setMaxInBufferCapacity(int capacity)
Sets the maximum capacity for the session's input buffer.
|
DefaultSessionConfig |
setMaxSSLApplicationBufferSizeRatio(int ratio)
Sets the ratio that is used to calculate the maximum size of the SSL
application buffers.
|
DefaultSessionConfig |
setMaxSSLNetworkBufferSizeRatio(int ratio)
Sets the ratio that is used to calculate the maximum size of the SSL
network buffers.
|
DefaultSessionConfig |
setMaxWriteSpinCount(int count)
Configures the maximum loop count for write operations performed by the
selector loop before returning control to the NIO selector or to other channel ready
for I/O operations.
|
DefaultSessionConfig |
setMinInBufferCapacity(int capacity)
Sets the minimum capacity for the session's input buffer.
|
DefaultSessionConfig |
setMinOutBufferCapacity(int capacity)
Sets the minimum capacity for the session's output buffer.
|
DefaultSessionConfig |
setOptimizeDataCopying(boolean optimize)
Configures if the processing of data should be optimized to reduce data
copying between byte buffers.
|
DefaultSessionConfig |
setThroughputCalculationInterval(long interval)
Sets the interval in milliseconds between each throughput calculation.
|
DefaultSessionConfig |
setWaitForInboundCloseMessage(boolean waitForCloseMessage)
Configures if the SNF4J framework should wait for the peer's
corresponding close message in situation when the closing was initiated
by calling the
EngineStreamSession.close() or
EngineStreamSession.quickClose() method. |
boolean |
waitForInboundCloseMessage()
Determines if the SNF4J framework should wait for the peer's corresponding
close message in situation when the closing was initiated by calling the
EngineStreamSession.close() or
EngineStreamSession.quickClose() method. |
public DefaultSessionConfig setMinInBufferCapacity(int capacity)
capacity
- the minimum capacity in bytespublic int getMinInBufferCapacity()
This value also determines the initial capacity of the input buffer.
Changing it once an associated session is created has no effect for the session.
The default value is 2048
getMinInBufferCapacity
in interface ISessionConfig
public DefaultSessionConfig setMaxInBufferCapacity(int capacity)
capacity
- the maximum capacity in bytespublic int getMaxInBufferCapacity()
Changing it once an associated session is created has no effect for the session.
The default value is 8192
getMaxInBufferCapacity
in interface ISessionConfig
public DefaultSessionConfig setMinOutBufferCapacity(int capacity)
capacity
- the minimum capacity in bytespublic int getMinOutBufferCapacity()
This configuration parameter is only valid for stream-oriented transmissions.
Changing it once an associated session is created has no effect for the session.
The default value is 2048
getMinOutBufferCapacity
in interface ISessionConfig
public DefaultSessionConfig setThroughputCalculationInterval(long interval)
interval
- the interval in milliseconds.public long getThroughputCalculationInterval()
The default value is 3000
getThroughputCalculationInterval
in interface ISessionConfig
public DefaultSessionConfig setIgnorePossiblyIncompleteDatagrams(boolean ignore)
ignore
- true
if possibly incomplete datagrams should be
ignored.public boolean ignorePossiblyIncompleteDatagrams()
If the size of received datagram is bigger than the size of session's input buffer the remainder of the datagram is silently discarded by the NIO API. In some protocols (e.g. TFTP) such situations would lead to erroneous processing of the received datagram.
To solve such situations we can ignore each datagram that fully filled up the session's input buffer. Considering that after detecting such datagram the size of the input buffer will be extended up to the max limit there is a big chance that there will be enough room in the buffer when the ignored (i.e. lost) datagram will be retransmitted by the remote end-point.
Changing it once an associated session is created has no effect for the session.
The default value is true
ignorePossiblyIncompleteDatagrams
in interface ISessionConfig
true
if possibly incomplete datagrams should be
ignoredDatagramChannel.read(java.nio.ByteBuffer)
public DefaultSessionConfig setOptimizeDataCopying(boolean optimize)
optimize
- true
if the processing of data should be
optimizedoptimizeDataCopying()
public boolean optimizeDataCopying()
Setting this parameter to true
instructs the write and send
methods that the passed data will be no longer used by the caller. In such
situation the write and send methods may, if possible, eliminate not needed
copy operations what can improve the performance.
In addition, setting this parameter to true
when the allocator
associated with the session supports releasing of no longer used buffers will
also cause data copy optimization between session's internal byte buffers. In
such situation user's implementation is responsible for releasing of no
longer used buffers that was passed to session handlers or codecs by calling
ISession.release(java.nio.ByteBuffer)
.
The default value is false
optimizeDataCopying
in interface ISessionConfig
true
if the data copy optimization should be enabledpublic DefaultSessionConfig setEndingAction(EndingAction action)
action
- en ending actionpublic EndingAction getEndingAction()
The default value is DEFAULT
getEndingAction
in interface ISessionConfig
public SSLEngine createSSLEngine(boolean clientMode) throws SSLEngineCreateException
By default it returns value returned by SSLContext.getDefault().createSSLEngine()
createSSLEngine
in interface ISessionConfig
clientMode
- true
if the engine should start its handshaking
in client modeSSLEngineCreateException
- when the SSL engine could not be createdpublic SSLEngine createSSLEngine(SocketAddress remoteAddress, boolean clientMode) throws SSLEngineCreateException
By default it returns value from the createSSLEngine(boolean)
method.
createSSLEngine
in interface ISessionConfig
remoteAddress
- the address of the remote peerclientMode
- true
if the engine should start its handshaking
in client modeSSLEngineCreateException
- when the SSL engine could not be createdpublic DefaultSessionConfig setMaxSSLApplicationBufferSizeRatio(int ratio)
ratio
- the ratioIllegalArgumentException
- if the ratio is less than 100getMaxSSLApplicationBufferSizeRatio()
public int getMaxSSLApplicationBufferSizeRatio()
SSLEngine
.
As the maximum size of the SSL application buffers cannot be less than the maximum SSL application packet size all values less than 100 will be silently ignored and treated as 100.
The default value is 100
getMaxSSLApplicationBufferSizeRatio
in interface ISessionConfig
SSLSession.getApplicationBufferSize()
public DefaultSessionConfig setMaxSSLNetworkBufferSizeRatio(int ratio)
ratio
- the ratioIllegalArgumentException
- if the ratio is less than 100getMaxSSLNetworkBufferSizeRatio()
public int getMaxSSLNetworkBufferSizeRatio()
SSLEngine
.
As the maximum size of the SSL network buffers cannot be less than the maximum SSL network packet size all values less than 100 will be silently ignored and treated as 100.
The default value is 100
getMaxSSLNetworkBufferSizeRatio
in interface ISessionConfig
SSLSession.getPacketBufferSize()
public boolean waitForInboundCloseMessage()
EngineStreamSession.close()
or
EngineStreamSession.quickClose()
method.
NOTE: Setting this value to true
may delay the closing of
the connection for an indefinite period of time. Usually it is not
required to wait for the close message (e.g. the TLS specification (RFC
2246))
The default value is false
waitForInboundCloseMessage
in interface ISessionConfig
true
to wait for the peer's corresponding close
message.public DefaultSessionConfig setWaitForInboundCloseMessage(boolean waitForCloseMessage)
EngineStreamSession.close()
or
EngineStreamSession.quickClose()
method.waitForCloseMessage
- true
to wait for the peer's corresponding close
message.waitForInboundCloseMessage()
public ICodecExecutor createCodecExecutor()
The default value is null
createCodecExecutor
in interface ISessionConfig
null
if decoding and encoding
is not required.public DefaultSessionConfig setEngineHandshakeTimeout(long timeout)
timeout
- the timeout in millisecondsgetEngineHandshakeTimeout()
public long getEngineHandshakeTimeout()
HandshakeTimeoutException
will be thrown and the session will be quickly
closed.
The default value is 60000
getEngineHandshakeTimeout
in interface ISessionConfig
public DefaultSessionConfig setDatagramServerSessionNoReopenPeriod(long period)
DatagramServerHandler
should block re-opening of a new session for the
remote peer which session has just been closed. The purpose of it is to
prevent opening of a new session as a result of receiving some delayed or
retransmitted datagrams.period
- the period in milliseconds or zero if the re-opening should
be allowed immediatelygetDatagramServerSessionNoReopenPeriod()
public long getDatagramServerSessionNoReopenPeriod()
DatagramServerHandler
should block re-opening of a new session for the
remote peer which session has just been closed. The purpose of it is to
prevent opening of a new session as a result of receiving some delayed or
retransmitted datagrams.
The default value is 60000
getDatagramServerSessionNoReopenPeriod
in interface ISessionConfig
public DefaultSessionConfig setMaxWriteSpinCount(int count)
It improves write throughput depending on the platform that JVM runs on.
count
- the maximum loop countgetMaxWriteSpinCount()
public int getMaxWriteSpinCount()
It improves write throughput depending on the platform that JVM runs on.
The default value is 16
getMaxWriteSpinCount
in interface ISessionConfig
Copyright © 2017–2021 SNF4J.ORG. All rights reserved.