public class NioParams extends Object
ConnectionFactory.| Constructor and Description |
|---|
NioParams() |
NioParams(NioParams nioParams) |
public NioParams()
public NioParams(NioParams nioParams)
public NioParams enableHostnameVerification()
NioParams instancesetSslEngineConfigurator(SslEngineConfigurator),
SslEngineConfigurators.ENABLE_HOSTNAME_VERIFICATIONpublic 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)
When idle for a few seconds (i.e. without any connection to perform IO for), a thread/task stops and is recreated if necessary.
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.
Connection shutdown can also be handled by a dedicated ExecutorService,
see setConnectionShutdownExecutor(ExecutorService).
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),
setConnectionShutdownExecutor(ExecutorService)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 SocketChannelConfigurator getSocketChannelConfigurator()
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 SslEngineConfigurator getSslEngineConfigurator()
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 ExecutorService getConnectionShutdownExecutor()
public NioParams setConnectionShutdownExecutor(ExecutorService connectionShutdownExecutor)
ExecutorService used for connection shutdown.
If not set, falls back to the NIO executor and then the thread factory.
This executor service is useful when strict control of the number of threads
is necessary, the application can experience the closing of several connections
at once, and automatic recovery is enabled. In such cases, the connection recovery
can take place in the same pool of threads as the NIO operations, which can
create deadlocks (all the threads of the pool are busy recovering, and there's no
thread left for NIO, so connections never recover).
Note it's developer's responsibility to shut down the executor when it is no longer needed.
Using the thread factory for such scenarios avoid the deadlocks, at the price of potentially creating many short-lived threads in case of massive connection lost.
With both the NIO and connection shutdown executor services set and configured accordingly, the application can control reliably the number of threads used.
connectionShutdownExecutor - the executor service to useNioParams instancesetNioExecutor(ExecutorService)public NioParams setByteBufferFactory(ByteBufferFactory byteBufferFactory)
ByteBuffers.
The default implementation creates heap-based ByteBuffers.
byteBufferFactory - the factory to useNioParams instanceByteBufferFactory,
DefaultByteBufferFactorypublic ByteBufferFactory getByteBufferFactory()
public NioParams setWriteQueueFactory(Function<NioContext,NioQueue> writeQueueFactory)
NioQueues.
The default uses a ArrayBlockingQueue.
public Function<NioContext,NioQueue> getWriteQueueFactory()
Copyright © 2021 VMware, Inc. or its affiliates.. All rights reserved.