Interface ChannelConfig
-
- All Known Subinterfaces:
DatagramChannelConfig,DomainDatagramChannelConfig,DomainSocketChannelConfig,DuplexChannelConfig,OioDatagramChannelConfig,OioServerSocketChannelConfig,OioSocketChannelConfig,QuicChannelConfig,QuicStreamChannelConfig,RxtxChannelConfig,SctpChannelConfig,SctpServerChannelConfig,ServerSocketChannelConfig,SocketChannelConfig,UdtChannelConfig,UdtServerChannelConfig
- All Known Implementing Classes:
DefaultChannelConfig,DefaultDatagramChannelConfig,DefaultOioServerSocketChannelConfig,DefaultOioSocketChannelConfig,DefaultSctpChannelConfig,DefaultSctpServerChannelConfig,DefaultServerSocketChannelConfig,DefaultSocketChannelConfig,DefaultUdtChannelConfig,DefaultUdtServerChannelConfig,EpollChannelConfig,EpollDatagramChannelConfig,EpollDomainDatagramChannelConfig,EpollDomainSocketChannelConfig,EpollServerChannelConfig,EpollServerSocketChannelConfig,EpollSocketChannelConfig,KQueueChannelConfig,KQueueDatagramChannelConfig,KQueueDomainDatagramChannelConfig,KQueueDomainSocketChannelConfig,KQueueServerChannelConfig,KQueueServerSocketChannelConfig,KQueueSocketChannelConfig
public interface ChannelConfigA set of configuration properties of aChannel.Please down-cast to more specific configuration type such as
SocketChannelConfigor usesetOptions(Map)to set the transport-specific properties:Channelch = ...;SocketChannelConfigcfg = (SocketChannelConfig) ch.getConfig(); cfg.setTcpNoDelay(false);Option map
An option map property is a dynamic write-only property which allows the configuration of aChannelwithout down-casting its associatedChannelConfig. To update an option map, please callsetOptions(Map).All
ChannelConfighas 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 inSocketChannelConfig.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description ByteBufAllocatorgetAllocator()ReturnsByteBufAllocatorwhich is used for the channel to allocate buffers.intgetConnectTimeoutMillis()Returns the connect timeout of the channel in milliseconds.intgetMaxMessagesPerRead()Deprecated.MessageSizeEstimatorgetMessageSizeEstimator()ReturnsMessageSizeEstimatorwhich is used for the channel to detect the size of a message.<T> TgetOption(ChannelOption<T> option)Return the value of the givenChannelOptionjava.util.Map<ChannelOption<?>,java.lang.Object>getOptions()Return all setChannelOption's.<T extends RecvByteBufAllocator>
TgetRecvByteBufAllocator()ReturnsRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.intgetWriteBufferHighWaterMark()Returns the high water mark of the write buffer.intgetWriteBufferLowWaterMark()Returns the low water mark of the write buffer.WriteBufferWaterMarkgetWriteBufferWaterMark()Returns theWriteBufferWaterMarkwhich is used for setting the high and low water mark of the write buffer.intgetWriteSpinCount()Returns the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)returns a non-zero value.booleanisAutoClose()Returnstrueif and only if theChannelwill be closed automatically and immediately on write failure.booleanisAutoRead()Returnstrueif and only ifChannelHandlerContext.read()will be invoked automatically so that a user application doesn't need to call it at all.ChannelConfigsetAllocator(ByteBufAllocator allocator)Set theByteBufAllocatorwhich is used for the channel to allocate buffers.ChannelConfigsetAutoClose(boolean autoClose)Sets whether theChannelshould be closed automatically and immediately on write failure.ChannelConfigsetAutoRead(boolean autoRead)Sets ifChannelHandlerContext.read()will be invoked automatically so that a user application doesn't need to call it at all.ChannelConfigsetConnectTimeoutMillis(int connectTimeoutMillis)Sets the connect timeout of the channel in milliseconds.ChannelConfigsetMaxMessagesPerRead(int maxMessagesPerRead)Deprecated.ChannelConfigsetMessageSizeEstimator(MessageSizeEstimator estimator)Set theMessageSizeEstimatorwhich is used for the channel to detect the size of a message.<T> booleansetOption(ChannelOption<T> option, T value)Sets a configuration property with the specified name and value.booleansetOptions(java.util.Map<ChannelOption<?>,?> options)Sets the configuration properties from the specifiedMap.ChannelConfigsetRecvByteBufAllocator(RecvByteBufAllocator allocator)Set theRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.ChannelConfigsetWriteBufferHighWaterMark(int writeBufferHighWaterMark)Sets the high water mark of the write buffer.ChannelConfigsetWriteBufferLowWaterMark(int writeBufferLowWaterMark)Sets the low water mark of the write buffer.ChannelConfigsetWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)Set theWriteBufferWaterMarkwhich is used for setting the high and low water mark of the write buffer.ChannelConfigsetWriteSpinCount(int writeSpinCount)Sets the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)returns a non-zero value.
-
-
-
Method Detail
-
getOptions
java.util.Map<ChannelOption<?>,java.lang.Object> getOptions()
Return all setChannelOption's.
-
setOptions
boolean setOptions(java.util.Map<ChannelOption<?>,?> options)
Sets the configuration properties from the specifiedMap.
-
getOption
<T> T getOption(ChannelOption<T> option)
Return the value of the givenChannelOption
-
setOption
<T> boolean setOption(ChannelOption<T> option, T value)
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:
trueif and only if the property has been set
-
getConnectTimeoutMillis
int getConnectTimeoutMillis()
Returns the connect timeout of the channel in milliseconds. If theChanneldoes not support connect operation, this property is not used at all, and therefore will be ignored.- Returns:
- the connect timeout in milliseconds.
0if disabled.
-
setConnectTimeoutMillis
ChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis)
Sets the connect timeout of the channel in milliseconds. If theChanneldoes not support connect operation, this property is not used at all, and therefore will be ignored.- Parameters:
connectTimeoutMillis- the connect timeout in milliseconds.0to disable.
-
getMaxMessagesPerRead
@Deprecated int getMaxMessagesPerRead()
Deprecated.UseMaxMessagesRecvByteBufAllocatorandMaxMessagesRecvByteBufAllocator.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 ChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead)
Deprecated.UseMaxMessagesRecvByteBufAllocatorandMaxMessagesRecvByteBufAllocator.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
ChannelConfig setWriteSpinCount(int writeSpinCount)
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:
java.lang.IllegalArgumentException- if the specified value is0or less than0
-
getAllocator
ByteBufAllocator getAllocator()
ReturnsByteBufAllocatorwhich is used for the channel to allocate buffers.
-
setAllocator
ChannelConfig setAllocator(ByteBufAllocator allocator)
Set theByteBufAllocatorwhich is used for the channel to allocate buffers.
-
getRecvByteBufAllocator
<T extends RecvByteBufAllocator> T getRecvByteBufAllocator()
ReturnsRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.
-
setRecvByteBufAllocator
ChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator)
Set theRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.
-
isAutoRead
boolean isAutoRead()
Returnstrueif 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
ChannelConfig setAutoRead(boolean autoRead)
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()
Returnstrueif and only if theChannelwill be closed automatically and immediately on write failure. The default istrue.
-
setAutoClose
ChannelConfig setAutoClose(boolean autoClose)
Sets whether theChannelshould 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
ChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark)
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 returntrueagain.
-
setWriteBufferLowWaterMark
ChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark)
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 returntrueagain.
-
getMessageSizeEstimator
MessageSizeEstimator getMessageSizeEstimator()
ReturnsMessageSizeEstimatorwhich is used for the channel to detect the size of a message.
-
setMessageSizeEstimator
ChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator)
Set theMessageSizeEstimatorwhich is used for the channel to detect the size of a message.
-
getWriteBufferWaterMark
WriteBufferWaterMark getWriteBufferWaterMark()
Returns theWriteBufferWaterMarkwhich is used for setting the high and low water mark of the write buffer.
-
setWriteBufferWaterMark
ChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
Set theWriteBufferWaterMarkwhich is used for setting the high and low water mark of the write buffer.
-
-