public class DefaultChannelConfig extends java.lang.Object implements ChannelConfig
ChannelConfig implementation.| Modifier and Type | Field and Description |
|---|---|
private ByteBufAllocator |
allocator |
private boolean |
autoClose |
private int |
autoRead |
private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<DefaultChannelConfig> |
AUTOREAD_UPDATER |
protected Channel |
channel |
private int |
connectTimeoutMillis |
private static int |
DEFAULT_CONNECT_TIMEOUT |
private static MessageSizeEstimator |
DEFAULT_MSG_SIZE_ESTIMATOR |
private MessageSizeEstimator |
msgSizeEstimator |
private boolean |
pinEventExecutor |
private RecvByteBufAllocator |
rcvBufAllocator |
private static java.util.concurrent.atomic.AtomicReferenceFieldUpdater<DefaultChannelConfig,WriteBufferWaterMark> |
WATERMARK_UPDATER |
private WriteBufferWaterMark |
writeBufferWaterMark |
private int |
writeSpinCount |
| Modifier | Constructor and Description |
|---|---|
|
DefaultChannelConfig(Channel channel) |
protected |
DefaultChannelConfig(Channel channel,
RecvByteBufAllocator allocator) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
autoReadCleared()
|
ByteBufAllocator |
getAllocator()
Returns
ByteBufAllocator which is used for the channel
to allocate buffers. |
int |
getConnectTimeoutMillis()
Returns the connect timeout of the channel in milliseconds.
|
int |
getMaxMessagesPerRead()
Deprecated.
|
MessageSizeEstimator |
getMessageSizeEstimator()
Returns
MessageSizeEstimator which is used for the channel
to detect the size of a message. |
<T> T |
getOption(ChannelOption<T> option)
Return the value of the given
ChannelOption |
java.util.Map<ChannelOption<?>,java.lang.Object> |
getOptions()
Return all set
ChannelOption's. |
protected java.util.Map<ChannelOption<?>,java.lang.Object> |
getOptions(java.util.Map<ChannelOption<?>,java.lang.Object> result,
ChannelOption<?>... options) |
private boolean |
getPinEventExecutorPerGroup() |
<T extends RecvByteBufAllocator> |
getRecvByteBufAllocator()
Returns
RecvByteBufAllocator which is used for the channel to allocate receive buffers. |
int |
getWriteBufferHighWaterMark()
Returns the high water mark of the write buffer.
|
int |
getWriteBufferLowWaterMark()
Returns the low water mark of the write buffer.
|
WriteBufferWaterMark |
getWriteBufferWaterMark()
Returns the
WriteBufferWaterMark which is used for setting the high and low
water mark of the write buffer. |
int |
getWriteSpinCount()
Returns the maximum loop count for a write operation until
WritableByteChannel.write(ByteBuffer) returns a non-zero value. |
boolean |
isAutoClose() |
boolean |
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. |
ChannelConfig |
setAllocator(ByteBufAllocator allocator)
Set the
ByteBufAllocator which is used for the channel
to allocate buffers. |
ChannelConfig |
setAutoClose(boolean autoClose) |
ChannelConfig |
setAutoRead(boolean autoRead)
Sets if
ChannelHandlerContext.read() will be invoked automatically so that a user application doesn't
need to call it at all. |
ChannelConfig |
setConnectTimeoutMillis(int connectTimeoutMillis)
Sets the connect timeout of the channel in milliseconds.
|
ChannelConfig |
setMaxMessagesPerRead(int maxMessagesPerRead)
Deprecated.
|
ChannelConfig |
setMessageSizeEstimator(MessageSizeEstimator estimator)
Set the
MessageSizeEstimator 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(java.util.Map<ChannelOption<?>,?> options)
Sets the configuration properties from the specified
Map. |
private ChannelConfig |
setPinEventExecutorPerGroup(boolean pinEventExecutor) |
ChannelConfig |
setRecvByteBufAllocator(RecvByteBufAllocator allocator)
Set the
RecvByteBufAllocator which is used for the channel to allocate receive buffers. |
private void |
setRecvByteBufAllocator(RecvByteBufAllocator allocator,
ChannelMetadata metadata)
Set the
RecvByteBufAllocator which is used for the channel to allocate receive buffers. |
ChannelConfig |
setWriteBufferHighWaterMark(int writeBufferHighWaterMark)
Sets the high water mark of the write buffer.
|
ChannelConfig |
setWriteBufferLowWaterMark(int writeBufferLowWaterMark)
Sets the low water mark of the write buffer.
|
ChannelConfig |
setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
Set the
WriteBufferWaterMark which is used for setting the high and low
water mark of the write buffer. |
ChannelConfig |
setWriteSpinCount(int writeSpinCount)
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) |
private static final MessageSizeEstimator DEFAULT_MSG_SIZE_ESTIMATOR
private static final int DEFAULT_CONNECT_TIMEOUT
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<DefaultChannelConfig> AUTOREAD_UPDATER
private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<DefaultChannelConfig,WriteBufferWaterMark> WATERMARK_UPDATER
protected final Channel channel
private volatile ByteBufAllocator allocator
private volatile RecvByteBufAllocator rcvBufAllocator
private volatile MessageSizeEstimator msgSizeEstimator
private volatile int connectTimeoutMillis
private volatile int writeSpinCount
private volatile int autoRead
private volatile boolean autoClose
private volatile WriteBufferWaterMark writeBufferWaterMark
private volatile boolean pinEventExecutor
public DefaultChannelConfig(Channel channel)
protected DefaultChannelConfig(Channel channel, RecvByteBufAllocator allocator)
public java.util.Map<ChannelOption<?>,java.lang.Object> getOptions()
ChannelConfigChannelOption's.getOptions in interface ChannelConfigprotected java.util.Map<ChannelOption<?>,java.lang.Object> getOptions(java.util.Map<ChannelOption<?>,java.lang.Object> result, ChannelOption<?>... options)
public boolean setOptions(java.util.Map<ChannelOption<?>,?> options)
ChannelConfigMap.setOptions in interface ChannelConfigpublic <T> T getOption(ChannelOption<T> option)
ChannelConfigChannelOptiongetOption in interface ChannelConfigpublic <T> boolean setOption(ChannelOption<T> option, T value)
ChannelConfig
public boolean setOption(ChannelOption<T> option, T value) {
if (super.setOption(option, value)) {
return true;
}
if (option.equals(additionalOption)) {
....
return true;
}
return false;
}
setOption in interface ChannelConfigtrue if and only if the property has been setprotected <T> void validate(ChannelOption<T> option, T value)
public int getConnectTimeoutMillis()
ChannelConfigChannel does not support connect operation, this property is not
used at all, and therefore will be ignored.getConnectTimeoutMillis in interface ChannelConfig0 if disabled.public ChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis)
ChannelConfigChannel does not support connect operation, this property is not
used at all, and therefore will be ignored.setConnectTimeoutMillis in interface ChannelConfigconnectTimeoutMillis - the connect timeout in milliseconds.
0 to disable.@Deprecated public int getMaxMessagesPerRead()
getMaxMessagesPerRead in interface ChannelConfigjava.lang.IllegalStateException - if getRecvByteBufAllocator() does not return an object of type
MaxMessagesRecvByteBufAllocator.@Deprecated public ChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead)
setMaxMessagesPerRead in interface ChannelConfigjava.lang.IllegalStateException - if getRecvByteBufAllocator() does not return an object of type
MaxMessagesRecvByteBufAllocator.public int getWriteSpinCount()
ChannelConfigWritableByteChannel.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.getWriteSpinCount in interface ChannelConfigpublic ChannelConfig setWriteSpinCount(int writeSpinCount)
ChannelConfigWritableByteChannel.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.setWriteSpinCount in interface ChannelConfigpublic ByteBufAllocator getAllocator()
ChannelConfigByteBufAllocator which is used for the channel
to allocate buffers.getAllocator in interface ChannelConfigpublic ChannelConfig setAllocator(ByteBufAllocator allocator)
ChannelConfigByteBufAllocator which is used for the channel
to allocate buffers.setAllocator in interface ChannelConfigpublic <T extends RecvByteBufAllocator> T getRecvByteBufAllocator()
ChannelConfigRecvByteBufAllocator which is used for the channel to allocate receive buffers.getRecvByteBufAllocator in interface ChannelConfigpublic ChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator)
ChannelConfigRecvByteBufAllocator which is used for the channel to allocate receive buffers.setRecvByteBufAllocator in interface ChannelConfigprivate void setRecvByteBufAllocator(RecvByteBufAllocator allocator, ChannelMetadata metadata)
RecvByteBufAllocator which is used for the channel to allocate receive buffers.allocator - the allocator to set.metadata - Used to set the ChannelMetadata.defaultMaxMessagesPerRead() if allocator
is of type MaxMessagesRecvByteBufAllocator.public boolean isAutoRead()
ChannelConfigtrue 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.isAutoRead in interface ChannelConfigpublic ChannelConfig setAutoRead(boolean autoRead)
ChannelConfigChannelHandlerContext.read() will be invoked automatically so that a user application doesn't
need to call it at all. The default value is true.setAutoRead in interface ChannelConfigprotected void autoReadCleared()
public boolean isAutoClose()
isAutoClose in interface ChannelConfigpublic ChannelConfig setAutoClose(boolean autoClose)
setAutoClose in interface ChannelConfigpublic int getWriteBufferHighWaterMark()
ChannelConfigChannel.isWritable()
will start to return false.getWriteBufferHighWaterMark in interface ChannelConfigpublic ChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark)
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 return false.
setWriteBufferHighWaterMark in interface ChannelConfigpublic int getWriteBufferLowWaterMark()
ChannelConfigChannel.isWritable() will start to return
true again.getWriteBufferLowWaterMark in interface ChannelConfigpublic ChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark)
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 return
true again.
setWriteBufferLowWaterMark in interface ChannelConfigpublic ChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
ChannelConfigWriteBufferWaterMark which is used for setting the high and low
water mark of the write buffer.setWriteBufferWaterMark in interface ChannelConfigpublic WriteBufferWaterMark getWriteBufferWaterMark()
ChannelConfigWriteBufferWaterMark which is used for setting the high and low
water mark of the write buffer.getWriteBufferWaterMark in interface ChannelConfigpublic MessageSizeEstimator getMessageSizeEstimator()
ChannelConfigMessageSizeEstimator which is used for the channel
to detect the size of a message.getMessageSizeEstimator in interface ChannelConfigpublic ChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator)
ChannelConfigMessageSizeEstimator which is used for the channel
to detect the size of a message.setMessageSizeEstimator in interface ChannelConfigprivate ChannelConfig setPinEventExecutorPerGroup(boolean pinEventExecutor)
private boolean getPinEventExecutorPerGroup()