public class NioParams extends Object
ConnectionFactory
.Constructor and Description |
---|
NioParams() |
NioParams(NioParams nioParams) |
Modifier and Type | Method and Description |
---|---|
int |
getNbIoThreads() |
ExecutorService |
getNioExecutor() |
int |
getReadByteBufferSize() |
SocketChannelConfigurator |
getSocketChannelConfigurator() |
SslEngineConfigurator |
getSslEngineConfigurator() |
ThreadFactory |
getThreadFactory() |
int |
getWriteByteBufferSize() |
int |
getWriteEnqueuingTimeoutInMs() |
int |
getWriteQueueCapacity() |
NioParams |
setNbIoThreads(int nbIoThreads)
Sets the max number of threads/tasks used for NIO.
|
NioParams |
setNioExecutor(ExecutorService nioExecutor)
Sets the
ExecutorService to use for NIO threads/tasks. |
NioParams |
setReadByteBufferSize(int readByteBufferSize)
Sets the size in byte of the read
ByteBuffer used in the NIO loop. |
void |
setSocketChannelConfigurator(SocketChannelConfigurator configurator)
Set the
SocketChannel configurator. |
void |
setSslEngineConfigurator(SslEngineConfigurator configurator)
Set the
SSLEngine configurator. |
NioParams |
setThreadFactory(ThreadFactory threadFactory)
Sets the
ThreadFactory to use for NIO threads/tasks. |
NioParams |
setWriteByteBufferSize(int writeByteBufferSize)
Sets the size in byte of the write
ByteBuffer used in the NIO loop. |
NioParams |
setWriteEnqueuingTimeoutInMs(int writeEnqueuingTimeoutInMs)
Sets the timeout for queuing outbound frames.
|
NioParams |
setWriteQueueCapacity(int writeQueueCapacity)
Set the capacity of the queue used for outbound frames.
|
public NioParams()
public NioParams(NioParams nioParams)
public int getReadByteBufferSize()
public NioParams setReadByteBufferSize(int readByteBufferSize)
ByteBuffer
used in the NIO loop.
Default is 32768.
This parameter isn't used when using SSL/TLS, where ByteBuffer
size is set up according to the SSLSession
packet size.readByteBufferSize
- size of the ByteBuffer
for inbound dataNioParams
instancepublic int getWriteByteBufferSize()
public NioParams setWriteByteBufferSize(int writeByteBufferSize)
ByteBuffer
used in the NIO loop.
Default is 32768.
This parameter isn't used when using SSL/TLS, where ByteBuffer
size is set up according to the SSLSession
packet size.writeByteBufferSize
- size of the ByteBuffer
used for outbound dataNioParams
instancepublic int getNbIoThreads()
public NioParams setNbIoThreads(int nbIoThreads)
nbIoThreads
- NioParams
instancepublic int getWriteEnqueuingTimeoutInMs()
public NioParams setWriteEnqueuingTimeoutInMs(int writeEnqueuingTimeoutInMs)
BlockingQueue
before
being sent on the network by a IO thread.
If the IO thread cannot cope with the frames dispatch, the
BlockingQueue
gets filled up and blocks
(blocking the calling thread by the same occasion). This timeout is the
time the BlockingQueue
will wait before
rejecting the outbound frame. The calling thread will then received
an exception.
The appropriate value depends on the application scenarios:
rate of outbound data (published messages, acknowledgment, etc), network speed...writeEnqueuingTimeoutInMs
- NioParams
instancesetWriteQueueCapacity(int)
public ExecutorService getNioExecutor()
public NioParams setNioExecutor(ExecutorService nioExecutor)
ExecutorService
to use for NIO threads/tasks.
Default is to use the thread factory.
The ExecutorService
should be able to run the
number of requested IO threads, plus a few more, as it's also
used to dispatch the shutdown of connections.
It's developer's responsibility to shut down the executor
when it is no longer needed.
The thread factory isn't used if an executor service is set up.nioExecutor
- ExecutorService
used for IO threads and connection shutdownNioParams
instancesetNbIoThreads(int)
,
setThreadFactory(ThreadFactory)
public ThreadFactory getThreadFactory()
public NioParams setThreadFactory(ThreadFactory threadFactory)
ThreadFactory
to use for NIO threads/tasks.
Default is to use the ConnectionFactory
's
ThreadFactory
.
The ThreadFactory
is used to spawn the IO threads
and dispatch the shutdown of connections.threadFactory
- ThreadFactory
used for IO threads and connection shutdownNioParams
instancesetNbIoThreads(int)
,
setNioExecutor(ExecutorService)
public int getWriteQueueCapacity()
public NioParams setWriteQueueCapacity(int writeQueueCapacity)
writeQueueCapacity
- NioParams
instancesetWriteEnqueuingTimeoutInMs(int)
public void setSocketChannelConfigurator(SocketChannelConfigurator configurator)
SocketChannel
configurator.
This gets a chance to "configure" a socket channel
before it has been opened. The default implementation disables
Nagle's algorithm.configurator
- the configurator to usepublic SocketChannelConfigurator getSocketChannelConfigurator()
public void setSslEngineConfigurator(SslEngineConfigurator configurator)
SSLEngine
configurator.
This gets a change to "configure" the SSL engine
before the connection has been opened. This can be
used e.g. to set SSLParameters
.
The default implementation doesn't do anything.configurator
- the configurator to usepublic SslEngineConfigurator getSslEngineConfigurator()
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.