Top Description Fields Constructors Methods
io.netty.channel

public Class DefaultChannelConfig

extends Object
implements ChannelConfig
Class Inheritance
All Implemented Interfaces
io.netty.channel.ChannelConfig
Known Direct Subclasses
io.netty.channel.socket.DefaultDatagramChannelConfig, io.netty.channel.socket.DefaultServerSocketChannelConfig, io.netty.channel.socket.DefaultSocketChannelConfig
Imports
io.netty.buffer.ByteBufAllocator, io.netty.util.internal.ObjectUtil, java.util.IdentityHashMap, .Map, .Map.Entry, java.util.concurrent.atomic.AtomicIntegerFieldUpdater, .AtomicReferenceFieldUpdater

The default ChannelConfig implementation.

Field Summary

Modifier and TypeField and Description
private volatile ByteBufAllocator
private volatile boolean
private volatile int
private static final AtomicIntegerFieldUpdater<DefaultChannelConfig>
protected final Channel
private volatile int
private static final int
private static final MessageSizeEstimator
private volatile int
private volatile MessageSizeEstimator
private volatile boolean
private volatile RecvByteBufAllocator
private static final AtomicReferenceFieldUpdater<DefaultChannelConfig, WriteBufferWaterMark>
private volatile WriteBufferWaterMark
private volatile int

Constructor Summary

AccessConstructor and Description
public
protected

Method Summary

Modifier and TypeMethod and Description
protected void
autoReadCleared()

Is called once setAutoRead(boolean) is called with false and isAutoRead() was true before.

public ByteBufAllocator
getAllocator()

Implements io.netty.channel.ChannelConfig.getAllocator.

Returns ByteBufAllocator which is used for the channel to allocate buffers.
public int
getConnectTimeoutMillis()

Implements io.netty.channel.ChannelConfig.getConnectTimeoutMillis.

Returns the connect timeout of the channel in milliseconds.
public int
public int
getMaxMessagesPerWrite()

Get the maximum number of message to write per eventloop run.

public MessageSizeEstimator
getMessageSizeEstimator()

Implements io.netty.channel.ChannelConfig.getMessageSizeEstimator.

Returns MessageSizeEstimator which is used for the channel to detect the size of a message.
public <T> T
getOption(ChannelOption<T> option)

Implements io.netty.channel.ChannelConfig.getOption.

Return the value of the given ChannelOption
public Map<ChannelOption<?>, Object>
protected Map<ChannelOption<?>, Object>
getOptions(Map<ChannelOption<?>, Object> result, ChannelOption<?>... options)

private boolean
public <T extends RecvByteBufAllocator> T
getRecvByteBufAllocator()

Implements io.netty.channel.ChannelConfig.getRecvByteBufAllocator.

Returns RecvByteBufAllocator which is used for the channel to allocate receive buffers.
public int
getWriteBufferHighWaterMark()

Implements io.netty.channel.ChannelConfig.getWriteBufferHighWaterMark.

Returns the high water mark of the write buffer.
public int
getWriteBufferLowWaterMark()

Implements io.netty.channel.ChannelConfig.getWriteBufferLowWaterMark.

Returns the low water mark of the write buffer.
public WriteBufferWaterMark
getWriteBufferWaterMark()

Implements io.netty.channel.ChannelConfig.getWriteBufferWaterMark.

Returns the WriteBufferWaterMark which is used for setting the high and low water mark of the write buffer.
public int
getWriteSpinCount()

Implements io.netty.channel.ChannelConfig.getWriteSpinCount.

Returns the maximum loop count for a write operation until WritableByteChannel#write(ByteBuffer) returns a non-zero value.
public boolean
isAutoClose()

Implements io.netty.channel.ChannelConfig.isAutoClose.

Returns true if and only if the Channel will be closed automatically and immediately on write failure.
public boolean
isAutoRead()

Implements io.netty.channel.ChannelConfig.isAutoRead.

Returns true if and only if ChannelHandlerContext#read() will be invoked automatically so that a user application doesn't need to call it at all.
public ChannelConfig
setAllocator(ByteBufAllocator allocator)

Implements io.netty.channel.ChannelConfig.setAllocator.

Set the ByteBufAllocator which is used for the channel to allocate buffers.
public ChannelConfig
setAutoClose(boolean autoClose)

Implements io.netty.channel.ChannelConfig.setAutoClose.

Sets whether the Channel should be closed automatically and immediately on write failure.
public ChannelConfig
setAutoRead(boolean autoRead)

Implements io.netty.channel.ChannelConfig.setAutoRead.

Sets if ChannelHandlerContext#read() will be invoked automatically so that a user application doesn't need to call it at all.
public ChannelConfig
setConnectTimeoutMillis(int
the connect timeout in milliseconds. 0 to disable.
connectTimeoutMillis
)

Implements io.netty.channel.ChannelConfig.setConnectTimeoutMillis.

Sets the connect timeout of the channel in milliseconds.
public ChannelConfig
public ChannelConfig
setMaxMessagesPerWrite(int maxMessagesPerWrite)

Set the maximum number of message to write per eventloop run.

public ChannelConfig
setMessageSizeEstimator(MessageSizeEstimator estimator)

Implements io.netty.channel.ChannelConfig.setMessageSizeEstimator.

Set the MessageSizeEstimator which is used for the channel to detect the size of a message.
public <T> boolean
setOption(ChannelOption<T> option, T value)

Implements io.netty.channel.ChannelConfig.setOption.

Sets a configuration property with the specified name and value.
public boolean
setOptions(Map<ChannelOption<?>, ?> options)

Implements io.netty.channel.ChannelConfig.setOptions.

Sets the configuration properties from the specified Map.
private ChannelConfig
setPinEventExecutorPerGroup(boolean pinEventExecutor)

public ChannelConfig
setRecvByteBufAllocator(RecvByteBufAllocator allocator)

Implements io.netty.channel.ChannelConfig.setRecvByteBufAllocator.

Set the RecvByteBufAllocator which is used for the channel to allocate receive buffers.
private void
setRecvByteBufAllocator(RecvByteBufAllocator
the allocator to set.
allocator
,
ChannelMetadata metadata)

Set the RecvByteBufAllocator which is used for the channel to allocate receive buffers.

public ChannelConfig
setWriteBufferHighWaterMark(int writeBufferHighWaterMark)

Implements io.netty.channel.ChannelConfig.setWriteBufferHighWaterMark.

Sets the high water mark of the write buffer.

public ChannelConfig
setWriteBufferLowWaterMark(int writeBufferLowWaterMark)

Implements io.netty.channel.ChannelConfig.setWriteBufferLowWaterMark.

Sets the low water mark of the write buffer.

public ChannelConfig
setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)

Implements io.netty.channel.ChannelConfig.setWriteBufferWaterMark.

Set the WriteBufferWaterMark which is used for setting the high and low water mark of the write buffer.
public ChannelConfig
setWriteSpinCount(int writeSpinCount)

Implements io.netty.channel.ChannelConfig.setWriteSpinCount.

Sets the maximum loop count for a write operation until WritableByteChannel#write(ByteBuffer) returns a non-zero value.
protected <T> void
validate(ChannelOption<T> option, T value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allocatorback to summary
private volatile ByteBufAllocator allocator
autoCloseback to summary
private volatile boolean autoClose
autoReadback to summary
private volatile int autoRead
Annotations
@SuppressWarnings:FieldMayBeFinal
AUTOREAD_UPDATERback to summary
private static final AtomicIntegerFieldUpdater<DefaultChannelConfig> AUTOREAD_UPDATER
channelback to summary
protected final Channel channel
connectTimeoutMillisback to summary
private volatile int connectTimeoutMillis
DEFAULT_CONNECT_TIMEOUTback to summary
private static final int DEFAULT_CONNECT_TIMEOUT
DEFAULT_MSG_SIZE_ESTIMATORback to summary
private static final MessageSizeEstimator DEFAULT_MSG_SIZE_ESTIMATOR
maxMessagesPerWriteback to summary
private volatile int maxMessagesPerWrite
msgSizeEstimatorback to summary
private volatile MessageSizeEstimator msgSizeEstimator
pinEventExecutorback to summary
private volatile boolean pinEventExecutor
rcvBufAllocatorback to summary
private volatile RecvByteBufAllocator rcvBufAllocator
WATERMARK_UPDATERback to summary
private static final AtomicReferenceFieldUpdater<DefaultChannelConfig, WriteBufferWaterMark> WATERMARK_UPDATER
writeBufferWaterMarkback to summary
private volatile WriteBufferWaterMark writeBufferWaterMark
writeSpinCountback to summary
private volatile int writeSpinCount

Constructor Detail

DefaultChannelConfigback to summary
public DefaultChannelConfig(Channel channel)
DefaultChannelConfigback to summary
protected DefaultChannelConfig(Channel channel, RecvByteBufAllocator allocator)

Method Detail

autoReadClearedback to summary
protected void autoReadCleared()

Is called once setAutoRead(boolean) is called with false and isAutoRead() was true before.

getAllocatorback to summary
public ByteBufAllocator getAllocator()

Implements io.netty.channel.ChannelConfig.getAllocator.

Doc from io.netty.channel.ChannelConfig.getAllocator.

Returns ByteBufAllocator which is used for the channel to allocate buffers.

Annotations
@Override
getConnectTimeoutMillisback to summary
public int getConnectTimeoutMillis()

Implements io.netty.channel.ChannelConfig.getConnectTimeoutMillis.

Doc from io.netty.channel.ChannelConfig.getConnectTimeoutMillis.

Returns the connect timeout of the channel in milliseconds. If the Channel does not support connect operation, this property is not used at all, and therefore will be ignored.

Returns:int

the connect timeout in milliseconds. 0 if disabled.

Annotations
@Override
getMaxMessagesPerReadback to summary
public int getMaxMessagesPerRead()

Implements io.netty.channel.ChannelConfig.getMaxMessagesPerRead.

Deprecated

Annotations
@Override
@Deprecated
Exceptions
IllegalStateException:
if getRecvByteBufAllocator() does not return an object of type MaxMessagesRecvByteBufAllocator.
getMaxMessagesPerWriteback to summary
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.

getMessageSizeEstimatorback to summary
public MessageSizeEstimator getMessageSizeEstimator()

Implements io.netty.channel.ChannelConfig.getMessageSizeEstimator.

Doc from io.netty.channel.ChannelConfig.getMessageSizeEstimator.

Returns MessageSizeEstimator which is used for the channel to detect the size of a message.

Annotations
@Override
getOptionback to summary
public <T> T getOption(ChannelOption<T> option)

Implements io.netty.channel.ChannelConfig.getOption.

Doc from io.netty.channel.ChannelConfig.getOption.

Return the value of the given ChannelOption

Annotations
@Override
@SuppressWarnings:unchecked, deprecation
getOptionsback to summary
public Map<ChannelOption<?>, Object> getOptions()

Implements io.netty.channel.ChannelConfig.getOptions.

Doc from io.netty.channel.ChannelConfig.getOptions.

Return all set ChannelOption's.

Annotations
@Override
@SuppressWarnings:deprecation
getOptionsback to summary
protected Map<ChannelOption<?>, Object> getOptions(Map<ChannelOption<?>, Object> result, ChannelOption<?>... options)
getPinEventExecutorPerGroupback to summary
private boolean getPinEventExecutorPerGroup()
getRecvByteBufAllocatorback to summary
public <T extends RecvByteBufAllocator> T getRecvByteBufAllocator()

Implements io.netty.channel.ChannelConfig.getRecvByteBufAllocator.

Doc from io.netty.channel.ChannelConfig.getRecvByteBufAllocator.

Returns RecvByteBufAllocator which is used for the channel to allocate receive buffers.

Annotations
@SuppressWarnings:unchecked
@Override
getWriteBufferHighWaterMarkback to summary
public int getWriteBufferHighWaterMark()

Implements io.netty.channel.ChannelConfig.getWriteBufferHighWaterMark.

Doc from io.netty.channel.ChannelConfig.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 return false.

Annotations
@Override
getWriteBufferLowWaterMarkback to summary
public int getWriteBufferLowWaterMark()

Implements io.netty.channel.ChannelConfig.getWriteBufferLowWaterMark.

Doc from io.netty.channel.ChannelConfig.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 return true again.

Annotations
@Override
getWriteBufferWaterMarkback to summary
public WriteBufferWaterMark getWriteBufferWaterMark()

Implements io.netty.channel.ChannelConfig.getWriteBufferWaterMark.

Doc from io.netty.channel.ChannelConfig.getWriteBufferWaterMark.

Returns the WriteBufferWaterMark which is used for setting the high and low water mark of the write buffer.

Annotations
@Override
getWriteSpinCountback to summary
public int getWriteSpinCount()

Implements io.netty.channel.ChannelConfig.getWriteSpinCount.

Doc from io.netty.channel.ChannelConfig.getWriteSpinCount.

Returns the maximum loop count for a write operation until WritableByteChannel#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 is 16.

Annotations
@Override
isAutoCloseback to summary
public boolean isAutoClose()

Implements io.netty.channel.ChannelConfig.isAutoClose.

Doc from io.netty.channel.ChannelConfig.isAutoClose.

Returns true if and only if the Channel will be closed automatically and immediately on write failure. The default is true.

Annotations
@Override
isAutoReadback to summary
public boolean isAutoRead()

Implements io.netty.channel.ChannelConfig.isAutoRead.

Doc from io.netty.channel.ChannelConfig.isAutoRead.

Returns true if and only if ChannelHandlerContext#read() will be invoked automatically so that a user application doesn't need to call it at all. The default value is true.

Annotations
@Override
setAllocatorback to summary
public ChannelConfig setAllocator(ByteBufAllocator allocator)

Implements io.netty.channel.ChannelConfig.setAllocator.

Doc from io.netty.channel.ChannelConfig.setAllocator.

Set the ByteBufAllocator which is used for the channel to allocate buffers.

Annotations
@Override
setAutoCloseback to summary
public ChannelConfig setAutoClose(boolean autoClose)

Implements io.netty.channel.ChannelConfig.setAutoClose.

Doc from io.netty.channel.ChannelConfig.setAutoClose.

Sets whether the Channel should be closed automatically and immediately on write failure. The default is true.

Annotations
@Override
setAutoReadback to summary
public ChannelConfig setAutoRead(boolean autoRead)

Implements io.netty.channel.ChannelConfig.setAutoRead.

Doc from io.netty.channel.ChannelConfig.setAutoRead.

Sets if ChannelHandlerContext#read() will be invoked automatically so that a user application doesn't need to call it at all. The default value is true.

Annotations
@Override
setConnectTimeoutMillisback to summary
public ChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis)

Implements io.netty.channel.ChannelConfig.setConnectTimeoutMillis.

Doc from io.netty.channel.ChannelConfig.setConnectTimeoutMillis.

Sets the connect timeout of the channel in milliseconds. If the Channel does not support connect operation, this property is not used at all, and therefore will be ignored.

Parameters
connectTimeoutMillis:int

the connect timeout in milliseconds. 0 to disable.

Annotations
@Override
setMaxMessagesPerReadback to summary
public ChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead)

Implements io.netty.channel.ChannelConfig.setMaxMessagesPerRead.

Deprecated

Annotations
@Override
@Deprecated
Exceptions
IllegalStateException:
if getRecvByteBufAllocator() does not return an object of type MaxMessagesRecvByteBufAllocator.
setMaxMessagesPerWriteback to summary
public ChannelConfig setMaxMessagesPerWrite(int maxMessagesPerWrite)

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.

setMessageSizeEstimatorback to summary
public ChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator)

Implements io.netty.channel.ChannelConfig.setMessageSizeEstimator.

Doc from io.netty.channel.ChannelConfig.setMessageSizeEstimator.

Set the MessageSizeEstimator which is used for the channel to detect the size of a message.

Annotations
@Override
setOptionback to summary
public <T> boolean setOption(ChannelOption<T> option, T value)

Implements io.netty.channel.ChannelConfig.setOption.

Doc from io.netty.channel.ChannelConfig.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:boolean

true if and only if the property has been set

Annotations
@Override
@SuppressWarnings:deprecation
setOptionsback to summary
public boolean setOptions(Map<ChannelOption<?>, ?> options)

Implements io.netty.channel.ChannelConfig.setOptions.

Doc from io.netty.channel.ChannelConfig.setOptions.

Sets the configuration properties from the specified Map.

Annotations
@SuppressWarnings:unchecked
@Override
setPinEventExecutorPerGroupback to summary
private ChannelConfig setPinEventExecutorPerGroup(boolean pinEventExecutor)
setRecvByteBufAllocatorback to summary
public ChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator)

Implements io.netty.channel.ChannelConfig.setRecvByteBufAllocator.

Doc from io.netty.channel.ChannelConfig.setRecvByteBufAllocator.

Set the RecvByteBufAllocator which is used for the channel to allocate receive buffers.

Annotations
@Override
setRecvByteBufAllocatorback to summary
private void setRecvByteBufAllocator(RecvByteBufAllocator allocator, ChannelMetadata metadata)

Set the RecvByteBufAllocator which is used for the channel to allocate receive buffers.

Parameters
allocator:RecvByteBufAllocator

the allocator to set.

metadata:ChannelMetadata

Used to set the ChannelMetadata#defaultMaxMessagesPerRead() if allocator is of type MaxMessagesRecvByteBufAllocator.

setWriteBufferHighWaterMarkback to summary
public ChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark)

Implements io.netty.channel.ChannelConfig.setWriteBufferHighWaterMark.

Doc from io.netty.channel.ChannelConfig.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 return false.

Annotations
@Override
setWriteBufferLowWaterMarkback to summary
public ChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark)

Implements io.netty.channel.ChannelConfig.setWriteBufferLowWaterMark.

Doc from io.netty.channel.ChannelConfig.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 return true again.

Annotations
@Override
setWriteBufferWaterMarkback to summary
public ChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)

Implements io.netty.channel.ChannelConfig.setWriteBufferWaterMark.

Doc from io.netty.channel.ChannelConfig.setWriteBufferWaterMark.

Set the WriteBufferWaterMark which is used for setting the high and low water mark of the write buffer.

Annotations
@Override
setWriteSpinCountback to summary
public ChannelConfig setWriteSpinCount(int writeSpinCount)

Implements io.netty.channel.ChannelConfig.setWriteSpinCount.

Doc from io.netty.channel.ChannelConfig.setWriteSpinCount.

Sets the maximum loop count for a write operation until WritableByteChannel#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 is 16.

Annotations
@Override
validateback to summary
protected <T> void validate(ChannelOption<T> option, T value)