Package io.netty.channel
Class DefaultChannelConfig
java.lang.Object
io.netty.channel.DefaultChannelConfig
- All Implemented Interfaces:
ChannelConfig
- Direct Known Subclasses:
AbstractHttp2StreamChannel.Http2StreamChannelConfig
,DefaultDatagramChannelConfig
,DefaultSctpChannelConfig
,DefaultSctpServerChannelConfig
,DefaultServerSocketChannelConfig
,DefaultSocketChannelConfig
,EpollChannelConfig
,KQueueChannelConfig
,NioDomainSocketChannel.NioDomainSocketChannelConfig
,NioServerDomainSocketChannel.NioDomainServerSocketChannelConfig
The default
ChannelConfig
implementation.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ByteBufAllocator
private boolean
private int
private static final AtomicIntegerFieldUpdater
<DefaultChannelConfig> protected final Channel
private int
private static final int
private static final MessageSizeEstimator
private int
private MessageSizeEstimator
private boolean
private RecvByteBufAllocator
private static final AtomicReferenceFieldUpdater
<DefaultChannelConfig, WriteBufferWaterMark> private WriteBufferWaterMark
private int
-
Constructor Summary
ConstructorsModifierConstructorDescriptionDefaultChannelConfig
(Channel channel) protected
DefaultChannelConfig
(Channel channel, RecvByteBufAllocator allocator) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
ReturnsByteBufAllocator
which is used for the channel to allocate buffers.int
Returns the connect timeout of the channel in milliseconds.int
Deprecated.int
Get the maximum number of message to write per eventloop run.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.protected Map
<ChannelOption<?>, Object> getOptions
(Map<ChannelOption<?>, Object> result, ChannelOption<?>... options) private boolean
<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.setMaxMessagesPerWrite
(int maxMessagesPerWrite) Set the maximum number of message to write per eventloop run.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
.private ChannelConfig
setPinEventExecutorPerGroup
(boolean pinEventExecutor) setRecvByteBufAllocator
(RecvByteBufAllocator allocator) Set theRecvByteBufAllocator
which is used for the channel to allocate receive buffers.private void
setRecvByteBufAllocator
(RecvByteBufAllocator allocator, ChannelMetadata metadata) 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.protected <T> void
validate
(ChannelOption<T> option, T value)
-
Field Details
-
DEFAULT_MSG_SIZE_ESTIMATOR
-
DEFAULT_CONNECT_TIMEOUT
private static final int DEFAULT_CONNECT_TIMEOUT- See Also:
-
AUTOREAD_UPDATER
-
WATERMARK_UPDATER
private static final AtomicReferenceFieldUpdater<DefaultChannelConfig,WriteBufferWaterMark> WATERMARK_UPDATER -
channel
-
allocator
-
rcvBufAllocator
-
msgSizeEstimator
-
connectTimeoutMillis
private volatile int connectTimeoutMillis -
writeSpinCount
private volatile int writeSpinCount -
maxMessagesPerWrite
private volatile int maxMessagesPerWrite -
autoRead
private volatile int autoRead -
autoClose
private volatile boolean autoClose -
writeBufferWaterMark
-
pinEventExecutor
private volatile boolean pinEventExecutor
-
-
Constructor Details
-
DefaultChannelConfig
-
DefaultChannelConfig
-
-
Method Details
-
getOptions
Description copied from interface:ChannelConfig
Return all setChannelOption
's.- Specified by:
getOptions
in interfaceChannelConfig
-
getOptions
protected Map<ChannelOption<?>,Object> getOptions(Map<ChannelOption<?>, Object> result, ChannelOption<?>... options) -
setOptions
Description copied from interface:ChannelConfig
Sets the configuration properties from the specifiedMap
.- Specified by:
setOptions
in interfaceChannelConfig
-
getOption
Description copied from interface:ChannelConfig
Return the value of the givenChannelOption
- Specified by:
getOption
in interfaceChannelConfig
-
setOption
Description copied from interface:ChannelConfig
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; }
- Specified by:
setOption
in interfaceChannelConfig
- Returns:
true
if and only if the property has been set
-
validate
-
getConnectTimeoutMillis
public int getConnectTimeoutMillis()Description copied from interface:ChannelConfig
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.- Specified by:
getConnectTimeoutMillis
in interfaceChannelConfig
- Returns:
- the connect timeout in milliseconds.
0
if disabled.
-
setConnectTimeoutMillis
Description copied from interface:ChannelConfig
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.- Specified by:
setConnectTimeoutMillis
in interfaceChannelConfig
- Parameters:
connectTimeoutMillis
- the connect timeout in milliseconds.0
to disable.
-
getMaxMessagesPerRead
Deprecated.- Specified by:
getMaxMessagesPerRead
in interfaceChannelConfig
- Throws:
IllegalStateException
- ifgetRecvByteBufAllocator()
does not return an object of typeMaxMessagesRecvByteBufAllocator
.
-
setMaxMessagesPerRead
Deprecated.- Specified by:
setMaxMessagesPerRead
in interfaceChannelConfig
- Throws:
IllegalStateException
- ifgetRecvByteBufAllocator()
does not return an object of typeMaxMessagesRecvByteBufAllocator
.
-
getMaxMessagesPerWrite
public int getMaxMessagesPerWrite()Get the maximum number of message to write per eventloop run. Once this limit is reached we will continue to process other events before trying to write the remaining messages. -
setMaxMessagesPerWrite
Set the maximum number of message to write per eventloop run. Once this limit is reached we will continue to process other events before trying to write the remaining messages. -
getWriteSpinCount
public int getWriteSpinCount()Description copied from interface:ChannelConfig
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
.- Specified by:
getWriteSpinCount
in interfaceChannelConfig
-
setWriteSpinCount
Description copied from interface:ChannelConfig
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
.- Specified by:
setWriteSpinCount
in interfaceChannelConfig
-
getAllocator
Description copied from interface:ChannelConfig
ReturnsByteBufAllocator
which is used for the channel to allocate buffers.- Specified by:
getAllocator
in interfaceChannelConfig
-
setAllocator
Description copied from interface:ChannelConfig
Set theByteBufAllocator
which is used for the channel to allocate buffers.- Specified by:
setAllocator
in interfaceChannelConfig
-
getRecvByteBufAllocator
Description copied from interface:ChannelConfig
ReturnsRecvByteBufAllocator
which is used for the channel to allocate receive buffers.- Specified by:
getRecvByteBufAllocator
in interfaceChannelConfig
-
setRecvByteBufAllocator
Description copied from interface:ChannelConfig
Set theRecvByteBufAllocator
which is used for the channel to allocate receive buffers.- Specified by:
setRecvByteBufAllocator
in interfaceChannelConfig
-
setRecvByteBufAllocator
Set theRecvByteBufAllocator
which is used for the channel to allocate receive buffers.- Parameters:
allocator
- the allocator to set.metadata
- Used to set theChannelMetadata.defaultMaxMessagesPerRead()
ifallocator
is of typeMaxMessagesRecvByteBufAllocator
.
-
isAutoRead
public boolean isAutoRead()Description copied from interface:ChannelConfig
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
.- Specified by:
isAutoRead
in interfaceChannelConfig
-
setAutoRead
Description copied from interface:ChannelConfig
Sets ifChannelHandlerContext.read()
will be invoked automatically so that a user application doesn't need to call it at all. The default value istrue
.- Specified by:
setAutoRead
in interfaceChannelConfig
-
autoReadCleared
protected void autoReadCleared() -
isAutoClose
public boolean isAutoClose()Description copied from interface:ChannelConfig
Returnstrue
if and only if theChannel
will be closed automatically and immediately on write failure. The default istrue
.- Specified by:
isAutoClose
in interfaceChannelConfig
-
setAutoClose
Description copied from interface:ChannelConfig
Sets whether theChannel
should be closed automatically and immediately on write failure. The default istrue
.- Specified by:
setAutoClose
in interfaceChannelConfig
-
getWriteBufferHighWaterMark
public int getWriteBufferHighWaterMark()Description copied from interface:ChannelConfig
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
.- Specified by:
getWriteBufferHighWaterMark
in interfaceChannelConfig
-
setWriteBufferHighWaterMark
Description copied from interface:ChannelConfig
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
.- Specified by:
setWriteBufferHighWaterMark
in interfaceChannelConfig
-
getWriteBufferLowWaterMark
public int getWriteBufferLowWaterMark()Description copied from interface:ChannelConfig
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.- Specified by:
getWriteBufferLowWaterMark
in interfaceChannelConfig
-
setWriteBufferLowWaterMark
Description copied from interface:ChannelConfig
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.- Specified by:
setWriteBufferLowWaterMark
in interfaceChannelConfig
-
setWriteBufferWaterMark
Description copied from interface:ChannelConfig
Set theWriteBufferWaterMark
which is used for setting the high and low water mark of the write buffer.- Specified by:
setWriteBufferWaterMark
in interfaceChannelConfig
-
getWriteBufferWaterMark
Description copied from interface:ChannelConfig
Returns theWriteBufferWaterMark
which is used for setting the high and low water mark of the write buffer.- Specified by:
getWriteBufferWaterMark
in interfaceChannelConfig
-
getMessageSizeEstimator
Description copied from interface:ChannelConfig
ReturnsMessageSizeEstimator
which is used for the channel to detect the size of a message.- Specified by:
getMessageSizeEstimator
in interfaceChannelConfig
-
setMessageSizeEstimator
Description copied from interface:ChannelConfig
Set theMessageSizeEstimator
which is used for the channel to detect the size of a message.- Specified by:
setMessageSizeEstimator
in interfaceChannelConfig
-
setPinEventExecutorPerGroup
-
getPinEventExecutorPerGroup
private boolean getPinEventExecutorPerGroup()
-