Interface ChannelConfig
- All Known Subinterfaces:
DatagramChannelConfig
,DomainDatagramChannelConfig
,DomainSocketChannelConfig
,DuplexChannelConfig
,OioDatagramChannelConfig
,OioServerSocketChannelConfig
,OioSocketChannelConfig
,SctpChannelConfig
,SctpServerChannelConfig
,ServerSocketChannelConfig
,SocketChannelConfig
- All Known Implementing Classes:
AbstractHttp2StreamChannel.Http2StreamChannelConfig
,DefaultChannelConfig
,DefaultDatagramChannelConfig
,DefaultOioDatagramChannelConfig
,DefaultOioServerSocketChannelConfig
,DefaultOioSocketChannelConfig
,DefaultSctpChannelConfig
,DefaultSctpServerChannelConfig
,DefaultServerSocketChannelConfig
,DefaultSocketChannelConfig
,EpollChannelConfig
,EpollDatagramChannelConfig
,EpollDomainDatagramChannelConfig
,EpollDomainSocketChannelConfig
,EpollServerChannelConfig
,EpollServerSocketChannelConfig
,EpollSocketChannelConfig
,KQueueChannelConfig
,KQueueDatagramChannelConfig
,KQueueDomainDatagramChannelConfig
,KQueueDomainSocketChannelConfig
,KQueueServerChannelConfig
,KQueueServerSocketChannelConfig
,KQueueSocketChannelConfig
,NioDatagramChannelConfig
,NioDomainSocketChannel.NioDomainSocketChannelConfig
,NioSctpChannel.NioSctpChannelConfig
,NioSctpServerChannel.NioSctpServerChannelConfig
,NioServerDomainSocketChannel.NioDomainServerSocketChannelConfig
,NioServerSocketChannel.NioServerSocketChannelConfig
,NioSocketChannel.NioSocketChannelConfig
,OioSctpChannel.OioSctpChannelConfig
,OioSctpServerChannel.OioSctpServerChannelConfig
Channel
.
Please down-cast to more specific configuration type such as
SocketChannelConfig
or use setOptions(Map)
to set the
transport-specific properties:
Channel
ch = ...;SocketChannelConfig
cfg = (SocketChannelConfig
) ch.getConfig(); cfg.setTcpNoDelay(false);
Option map
An option map property is a dynamic write-only property which allows the configuration of aChannel
without down-casting its associated
ChannelConfig
. To update an option map, please call setOptions(Map)
.
All ChannelConfig
has the following options:
More options are available in the sub-types of ChannelConfig
. For
example, you can configure the parameters which are specific to a TCP/IP
socket as explained in SocketChannelConfig
.
-
Method Summary
Modifier and TypeMethodDescriptionReturnsByteBufAllocator
which is used for the channel to allocate buffers.int
Returns the connect timeout of the channel in milliseconds.int
Deprecated.ReturnsMessageSizeEstimator
which is used for the channel to detect the size of a message.<T> T
getOption
(ChannelOption<T> option) Return the value of the givenChannelOption
Map
<ChannelOption<?>, Object> Return all setChannelOption
's.<T extends RecvByteBufAllocator>
TReturnsRecvByteBufAllocator
which is used for the channel to allocate receive buffers.int
Returns the high water mark of the write buffer.int
Returns the low water mark of the write buffer.Returns theWriteBufferWaterMark
which is used for setting the high and low water mark of the write buffer.int
Returns the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)
returns a non-zero value.boolean
Returnstrue
if and only if theChannel
will be closed automatically and immediately on write failure.boolean
Returnstrue
if and only ifChannelHandlerContext.read()
will be invoked automatically so that a user application doesn't need to call it at all.setAllocator
(ByteBufAllocator allocator) Set theByteBufAllocator
which is used for the channel to allocate buffers.setAutoClose
(boolean autoClose) Sets whether theChannel
should be closed automatically and immediately on write failure.setAutoRead
(boolean autoRead) Sets ifChannelHandlerContext.read()
will be invoked automatically so that a user application doesn't need to call it at all.setConnectTimeoutMillis
(int connectTimeoutMillis) Sets the connect timeout of the channel in milliseconds.setMaxMessagesPerRead
(int maxMessagesPerRead) Deprecated.setMessageSizeEstimator
(MessageSizeEstimator estimator) Set theMessageSizeEstimator
which is used for the channel to detect the size of a message.<T> boolean
setOption
(ChannelOption<T> option, T value) Sets a configuration property with the specified name and value.boolean
setOptions
(Map<ChannelOption<?>, ?> options) Sets the configuration properties from the specifiedMap
.setRecvByteBufAllocator
(RecvByteBufAllocator allocator) Set theRecvByteBufAllocator
which is used for the channel to allocate receive buffers.setWriteBufferHighWaterMark
(int writeBufferHighWaterMark) Sets the high water mark of the write buffer.setWriteBufferLowWaterMark
(int writeBufferLowWaterMark) Sets the low water mark of the write buffer.setWriteBufferWaterMark
(WriteBufferWaterMark writeBufferWaterMark) Set theWriteBufferWaterMark
which is used for setting the high and low water mark of the write buffer.setWriteSpinCount
(int writeSpinCount) Sets the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)
returns a non-zero value.
-
Method Details
-
getOptions
Map<ChannelOption<?>,Object> getOptions()Return all setChannelOption
's. -
setOptions
Sets the configuration properties from the specifiedMap
. -
getOption
Return the value of the givenChannelOption
-
setOption
Sets a configuration property with the specified name and value. To override this method properly, you must call the super class:public boolean setOption(ChannelOption<T> option, T value) { if (super.setOption(option, value)) { return true; } if (option.equals(additionalOption)) { .... return true; } return false; }
- Returns:
true
if and only if the property has been set
-
getConnectTimeoutMillis
int getConnectTimeoutMillis()Returns the connect timeout of the channel in milliseconds. If theChannel
does not support connect operation, this property is not used at all, and therefore will be ignored.- Returns:
- the connect timeout in milliseconds.
0
if disabled.
-
setConnectTimeoutMillis
Sets the connect timeout of the channel in milliseconds. If theChannel
does not support connect operation, this property is not used at all, and therefore will be ignored.- Parameters:
connectTimeoutMillis
- the connect timeout in milliseconds.0
to disable.
-
getMaxMessagesPerRead
Deprecated.UseMaxMessagesRecvByteBufAllocator
andMaxMessagesRecvByteBufAllocator.maxMessagesPerRead()
.Returns the maximum number of messages to read per read loop. a
channelRead()
event. If this value is greater than 1, an event loop might attempt to read multiple times to procure multiple messages. -
setMaxMessagesPerRead
Deprecated.UseMaxMessagesRecvByteBufAllocator
andMaxMessagesRecvByteBufAllocator.maxMessagesPerRead(int)
.Sets the maximum number of messages to read per read loop. If this value is greater than 1, an event loop might attempt to read multiple times to procure multiple messages.
-
getWriteSpinCount
int getWriteSpinCount()Returns the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)
returns a non-zero value. It is similar to what a spin lock is used for in concurrency programming. It improves memory utilization and write throughput depending on the platform that JVM runs on. The default value is16
. -
setWriteSpinCount
Sets the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)
returns a non-zero value. It is similar to what a spin lock is used for in concurrency programming. It improves memory utilization and write throughput depending on the platform that JVM runs on. The default value is16
.- Throws:
IllegalArgumentException
- if the specified value is0
or less than0
-
getAllocator
ByteBufAllocator getAllocator()ReturnsByteBufAllocator
which is used for the channel to allocate buffers. -
setAllocator
Set theByteBufAllocator
which is used for the channel to allocate buffers. -
getRecvByteBufAllocator
ReturnsRecvByteBufAllocator
which is used for the channel to allocate receive buffers. -
setRecvByteBufAllocator
Set theRecvByteBufAllocator
which is used for the channel to allocate receive buffers. -
isAutoRead
boolean isAutoRead()Returnstrue
if and only ifChannelHandlerContext.read()
will be invoked automatically so that a user application doesn't need to call it at all. The default value istrue
. -
setAutoRead
Sets ifChannelHandlerContext.read()
will be invoked automatically so that a user application doesn't need to call it at all. The default value istrue
. -
isAutoClose
boolean isAutoClose()Returnstrue
if and only if theChannel
will be closed automatically and immediately on write failure. The default istrue
. -
setAutoClose
Sets whether theChannel
should be closed automatically and immediately on write failure. The default istrue
. -
getWriteBufferHighWaterMark
int getWriteBufferHighWaterMark()Returns the high water mark of the write buffer. If the number of bytes queued in the write buffer exceeds this value,Channel.isWritable()
will start to returnfalse
. -
setWriteBufferHighWaterMark
Sets the high water mark of the write buffer. If the number of bytes queued in the write buffer exceeds this value,
Channel.isWritable()
will start to returnfalse
. -
getWriteBufferLowWaterMark
int getWriteBufferLowWaterMark()Returns the low water mark of the write buffer. Once the number of bytes queued in the write buffer exceeded the high water mark and then dropped down below this value,Channel.isWritable()
will start to returntrue
again. -
setWriteBufferLowWaterMark
Sets the low water mark of the write buffer. Once the number of bytes queued in the write buffer exceeded the high water mark and then dropped down below this value,
Channel.isWritable()
will start to returntrue
again. -
getMessageSizeEstimator
MessageSizeEstimator getMessageSizeEstimator()ReturnsMessageSizeEstimator
which is used for the channel to detect the size of a message. -
setMessageSizeEstimator
Set theMessageSizeEstimator
which is used for the channel to detect the size of a message. -
getWriteBufferWaterMark
WriteBufferWaterMark getWriteBufferWaterMark()Returns theWriteBufferWaterMark
which is used for setting the high and low water mark of the write buffer. -
setWriteBufferWaterMark
Set theWriteBufferWaterMark
which is used for setting the high and low water mark of the write buffer.
-
MaxMessagesRecvByteBufAllocator
andMaxMessagesRecvByteBufAllocator.maxMessagesPerRead()
.