Skip to content

Commit dcf1f5c

Browse files
committed
Polish
References #380
1 parent d11e365 commit dcf1f5c

File tree

1 file changed

+54
-30
lines changed

1 file changed

+54
-30
lines changed

src/main/java/com/rabbitmq/client/impl/nio/NioParams.java

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,67 @@
2020
import com.rabbitmq.client.SslEngineConfigurator;
2121

2222
import javax.net.ssl.SSLEngine;
23-
import java.io.IOException;
2423
import java.util.concurrent.ExecutorService;
2524
import java.util.concurrent.ThreadFactory;
2625

2726
/**
2827
* Parameters used to configure the NIO mode of a {@link com.rabbitmq.client.ConnectionFactory}.
28+
*
2929
* @since 4.0.0
3030
*/
3131
public class NioParams {
3232

33-
/** size of the byte buffer used for inbound data */
33+
/**
34+
* size of the byte buffer used for inbound data
35+
*/
3436
private int readByteBufferSize = 32768;
3537

36-
/** size of the byte buffer used for outbound data */
38+
/**
39+
* size of the byte buffer used for outbound data
40+
*/
3741
private int writeByteBufferSize = 32768;
3842

39-
/** the max number of IO threads */
43+
/**
44+
* the max number of IO threads
45+
*/
4046
private int nbIoThreads = 1;
4147

42-
/** the timeout to enqueue outbound frames */
48+
/**
49+
* the timeout to enqueue outbound frames
50+
*/
4351
private int writeEnqueuingTimeoutInMs = 10 * 1000;
4452

45-
/** the capacity of the queue used for outbound frames */
53+
/**
54+
* the capacity of the queue used for outbound frames
55+
*/
4656
private int writeQueueCapacity = 10000;
4757

48-
/** the executor service used for IO threads and connections shutdown */
58+
/**
59+
* the executor service used for IO threads and connections shutdown
60+
*/
4961
private ExecutorService nioExecutor;
5062

51-
/** the thread factory used for IO threads and connections shutdown */
63+
/**
64+
* the thread factory used for IO threads and connections shutdown
65+
*/
5266
private ThreadFactory threadFactory;
5367

54-
/** the hook to configure the socket channel before it's open */
68+
/**
69+
* the hook to configure the socket channel before it's open
70+
*/
5571
private SocketChannelConfigurator socketChannelConfigurator = new DefaultSocketChannelConfigurator();
5672

57-
/** the hook to configure the SSL engine before the connection is open */
58-
private SslEngineConfigurator sslEngineConfigurator = sslEngine -> { };
73+
/**
74+
* the hook to configure the SSL engine before the connection is open
75+
*/
76+
private SslEngineConfigurator sslEngineConfigurator = sslEngine -> {
77+
};
5978

60-
/** the executor service used for connection shutdown */
79+
/**
80+
* the executor service used for connection shutdown
81+
*
82+
* @since 5.4.0
83+
*/
6184
private ExecutorService connectionShutdownExecutor;
6285

6386
public NioParams() {
@@ -82,7 +105,7 @@ public int getReadByteBufferSize() {
82105
/**
83106
* Sets the size in byte of the read {@link java.nio.ByteBuffer} used in the NIO loop.
84107
* Default is 32768.
85-
*
108+
* <p>
86109
* This parameter isn't used when using SSL/TLS, where {@link java.nio.ByteBuffer}
87110
* size is set up according to the {@link javax.net.ssl.SSLSession} packet size.
88111
*
@@ -104,7 +127,7 @@ public int getWriteByteBufferSize() {
104127
/**
105128
* Sets the size in byte of the write {@link java.nio.ByteBuffer} used in the NIO loop.
106129
* Default is 32768.
107-
*
130+
* <p>
108131
* This parameter isn't used when using SSL/TLS, where {@link java.nio.ByteBuffer}
109132
* size is set up according to the {@link javax.net.ssl.SSLSession} packet size.
110133
*
@@ -131,7 +154,7 @@ public int getNbIoThreads() {
131154
* 10 connections have been created).
132155
* Once a connection is created, it's assigned to a thread/task and
133156
* all its IO activity is handled by this thread/task.
134-
*
157+
* <p>
135158
* When idle for a few seconds (i.e. without any connection to perform IO for),
136159
* a thread/task stops and is recreated if necessary.
137160
*
@@ -155,14 +178,14 @@ public int getWriteEnqueuingTimeoutInMs() {
155178
* Every requests to the server is divided into frames
156179
* that are then queued in a {@link java.util.concurrent.BlockingQueue} before
157180
* being sent on the network by a IO thread.
158-
*
181+
* <p>
159182
* If the IO thread cannot cope with the frames dispatch, the
160183
* {@link java.util.concurrent.BlockingQueue} gets filled up and blocks
161184
* (blocking the calling thread by the same occasion). This timeout is the
162185
* time the {@link java.util.concurrent.BlockingQueue} will wait before
163186
* rejecting the outbound frame. The calling thread will then received
164187
* an exception.
165-
*
188+
* <p>
166189
* The appropriate value depends on the application scenarios:
167190
* rate of outbound data (published messages, acknowledgment, etc), network speed...
168191
*
@@ -182,17 +205,17 @@ public ExecutorService getNioExecutor() {
182205
/**
183206
* Sets the {@link ExecutorService} to use for NIO threads/tasks.
184207
* Default is to use the thread factory.
185-
*
208+
* <p>
186209
* The {@link ExecutorService} should be able to run the
187210
* number of requested IO threads, plus a few more, as it's also
188211
* used to dispatch the shutdown of connections.
189-
*
212+
* <p>
190213
* Connection shutdown can also be handled by a dedicated {@link ExecutorService},
191214
* see {@link #setConnectionShutdownExecutor(ExecutorService)}.
192-
*
215+
* <p>
193216
* It's developer's responsibility to shut down the executor
194217
* when it is no longer needed.
195-
*
218+
* <p>
196219
* The thread factory isn't used if an executor service is set up.
197220
*
198221
* @param nioExecutor {@link ExecutorService} used for IO threads and connection shutdown
@@ -214,7 +237,7 @@ public ThreadFactory getThreadFactory() {
214237
* Sets the {@link ThreadFactory} to use for NIO threads/tasks.
215238
* Default is to use the {@link com.rabbitmq.client.ConnectionFactory}'s
216239
* {@link ThreadFactory}.
217-
*
240+
* <p>
218241
* The {@link ThreadFactory} is used to spawn the IO threads
219242
* and dispatch the shutdown of connections.
220243
*
@@ -248,6 +271,10 @@ public NioParams setWriteQueueCapacity(int writeQueueCapacity) {
248271
return this;
249272
}
250273

274+
public SocketChannelConfigurator getSocketChannelConfigurator() {
275+
return socketChannelConfigurator;
276+
}
277+
251278
/**
252279
* Set the {@link java.nio.channels.SocketChannel} configurator.
253280
* This gets a chance to "configure" a socket channel
@@ -260,8 +287,8 @@ public void setSocketChannelConfigurator(SocketChannelConfigurator configurator)
260287
this.socketChannelConfigurator = configurator;
261288
}
262289

263-
public SocketChannelConfigurator getSocketChannelConfigurator() {
264-
return socketChannelConfigurator;
290+
public SslEngineConfigurator getSslEngineConfigurator() {
291+
return sslEngineConfigurator;
265292
}
266293

267294
/**
@@ -277,8 +304,8 @@ public void setSslEngineConfigurator(SslEngineConfigurator configurator) {
277304
this.sslEngineConfigurator = configurator;
278305
}
279306

280-
public SslEngineConfigurator getSslEngineConfigurator() {
281-
return sslEngineConfigurator;
307+
public ExecutorService getConnectionShutdownExecutor() {
308+
return connectionShutdownExecutor;
282309
}
283310

284311
/**
@@ -303,13 +330,10 @@ public SslEngineConfigurator getSslEngineConfigurator() {
303330
* @param connectionShutdownExecutor the executor service to use
304331
* @return this {@link NioParams} instance
305332
* @see NioParams#setNioExecutor(ExecutorService)
333+
* @since 5.4.0
306334
*/
307335
public NioParams setConnectionShutdownExecutor(ExecutorService connectionShutdownExecutor) {
308336
this.connectionShutdownExecutor = connectionShutdownExecutor;
309337
return this;
310338
}
311-
312-
public ExecutorService getConnectionShutdownExecutor() {
313-
return connectionShutdownExecutor;
314-
}
315339
}

0 commit comments

Comments
 (0)