public class DefaultSessionConfig extends Object implements ISessionConfig
| Constructor and Description |
|---|
DefaultSessionConfig() |
| Modifier and Type | Method and Description |
|---|---|
DefaultSessionConfig |
addSSLEngineBuilder(SSLEngineBuilder builder)
Adds a SSLEngine builder that will be used to create the SSLengine for
sessions associated with this configuration object.
|
boolean |
alwaysNotifiedBeingInPipeline()
Determines if the session being associated with the session pipeline should
be notified in a situation when the connection is closed and the processing
of the session was not initiated yet.
|
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.
|
SSLEngineBuilder |
getSSLEngineBuilder(boolean clientMode)
Returns the SSLEngine builder configured for specified handshaking mode.
|
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 |
removeSSLEngineBuilder(boolean clientMode)
Removes the SSLEngine builder configured for specified handshaking mode.
|
DefaultSessionConfig |
setAlwaysNotifiedBeingInPipeline(boolean notify)
Configures if the session being associated with the session pipeline should
be notified in a situation when the connection is closed and the processing
of the session was not initiated yet.
|
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 ISessionConfigpublic 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 ISessionConfigpublic 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 ISessionConfigpublic DefaultSessionConfig setThroughputCalculationInterval(long interval)
interval - the interval in milliseconds.public long getThroughputCalculationInterval()
The default value is 3000
getThroughputCalculationInterval in interface ISessionConfigpublic 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 ISessionConfigtrue 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 (calling
ISession.release(java.nio.ByteBuffer)) of no longer used buffers that was passed to session
handlers or codecs.
The default value is false
optimizeDataCopying in interface ISessionConfigtrue 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 ISessionConfigpublic DefaultSessionConfig addSSLEngineBuilder(SSLEngineBuilder builder)
Only two builders can be stored. One per handshaking mode: client or server.
builder - an SSLEngine builder to addpublic SSLEngineBuilder getSSLEngineBuilder(boolean clientMode)
clientMode - true to return the builder for SSL engines
handshaking in the client modenull if the builder is not
configuredpublic DefaultSessionConfig removeSSLEngineBuilder(boolean clientMode)
clientMode - true to remove the builder for SSL engines
handshaking in the client modepublic SSLEngine createSSLEngine(boolean clientMode) throws SSLEngineCreateException
By default, if no SSLEngine builder is configured for the specified
handshaking mode, it returns the engine created by calling the
SSLContext.getDefault().createSSLEngine()
createSSLEngine in interface ISessionConfigclientMode - 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 the engine created by calling the createSSLEngine(boolean) method.
createSSLEngine in interface ISessionConfigremoteAddress - 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 ISessionConfigSSLSession.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 ISessionConfigSSLSession.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 ISessionConfigtrue 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 ISessionConfignull 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 ISessionConfigpublic 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 ISessionConfigpublic 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 ISessionConfigpublic DefaultSessionConfig setAlwaysNotifiedBeingInPipeline(boolean notify)
If the returned value is false the session that was not processed yet
will not be notified (i.e. session events will not be fired). However, this
does not apply to the session that owns the pipeline as it will always be
notified.
notify - true to always notify the session being associated with
the pipelinealwaysNotifiedBeingInPipeline()public boolean alwaysNotifiedBeingInPipeline()
If the returned value is false the session that was not processed yet
will not be notified (i.e. session events will not be fired). However, this
does not apply to the session that owns the pipeline as it will always be
notified.
The default value is false
alwaysNotifiedBeingInPipeline in interface ISessionConfigtrue to always notify the session being associated with the
pipelineCopyright © 2017–2022 SNF4J.ORG. All rights reserved.