Package io.netty.channel
Class DefaultChannelConfig
- java.lang.Object
-
- io.netty.channel.DefaultChannelConfig
-
- All Implemented Interfaces:
ChannelConfig
- Direct Known Subclasses:
DefaultDatagramChannelConfig,DefaultSctpChannelConfig,DefaultSctpServerChannelConfig,DefaultServerSocketChannelConfig,DefaultSocketChannelConfig,DefaultUdtChannelConfig,EpollChannelConfig,KQueueChannelConfig
public class DefaultChannelConfig extends java.lang.Object implements ChannelConfig
The defaultChannelConfigimplementation.
-
-
Constructor Summary
Constructors Modifier Constructor Description DefaultChannelConfig(Channel channel)protectedDefaultChannelConfig(Channel channel, RecvByteBufAllocator allocator)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidautoReadCleared()ByteBufAllocatorgetAllocator()ReturnsByteBufAllocatorwhich is used for the channel to allocate buffers.intgetConnectTimeoutMillis()Returns the connect timeout of the channel in milliseconds.intgetMaxMessagesPerRead()Deprecated.intgetMaxMessagesPerWrite()Get the maximum number of message to write per eventloop run.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.protected java.util.Map<ChannelOption<?>,java.lang.Object>getOptions(java.util.Map<ChannelOption<?>,java.lang.Object> result, ChannelOption<?>... options)<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.ChannelConfigsetMaxMessagesPerWrite(int maxMessagesPerWrite)Set the maximum number of message to write per eventloop run.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.protected <T> voidvalidate(ChannelOption<T> option, T value)
-
-
-
Field Detail
-
channel
protected final Channel channel
-
-
Constructor Detail
-
DefaultChannelConfig
public DefaultChannelConfig(Channel channel)
-
DefaultChannelConfig
protected DefaultChannelConfig(Channel channel, RecvByteBufAllocator allocator)
-
-
Method Detail
-
getOptions
public java.util.Map<ChannelOption<?>,java.lang.Object> getOptions()
Description copied from interface:ChannelConfigReturn all setChannelOption's.- Specified by:
getOptionsin interfaceChannelConfig
-
getOptions
protected java.util.Map<ChannelOption<?>,java.lang.Object> getOptions(java.util.Map<ChannelOption<?>,java.lang.Object> result, ChannelOption<?>... options)
-
setOptions
public boolean setOptions(java.util.Map<ChannelOption<?>,?> options)
Description copied from interface:ChannelConfigSets the configuration properties from the specifiedMap.- Specified by:
setOptionsin interfaceChannelConfig
-
getOption
public <T> T getOption(ChannelOption<T> option)
Description copied from interface:ChannelConfigReturn the value of the givenChannelOption- Specified by:
getOptionin interfaceChannelConfig
-
setOption
public <T> boolean setOption(ChannelOption<T> option, T value)
Description copied from interface:ChannelConfigSets 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:
setOptionin interfaceChannelConfig- Returns:
trueif and only if the property has been set
-
validate
protected <T> void validate(ChannelOption<T> option, T value)
-
getConnectTimeoutMillis
public int getConnectTimeoutMillis()
Description copied from interface:ChannelConfigReturns 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.- Specified by:
getConnectTimeoutMillisin interfaceChannelConfig- Returns:
- the connect timeout in milliseconds.
0if disabled.
-
setConnectTimeoutMillis
public ChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis)
Description copied from interface:ChannelConfigSets 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.- Specified by:
setConnectTimeoutMillisin interfaceChannelConfig- Parameters:
connectTimeoutMillis- the connect timeout in milliseconds.0to disable.
-
getMaxMessagesPerRead
@Deprecated public int getMaxMessagesPerRead()
Deprecated.- Specified by:
getMaxMessagesPerReadin interfaceChannelConfig- Throws:
java.lang.IllegalStateException- ifgetRecvByteBufAllocator()does not return an object of typeMaxMessagesRecvByteBufAllocator.
-
setMaxMessagesPerRead
@Deprecated public ChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead)
Deprecated.- Specified by:
setMaxMessagesPerReadin interfaceChannelConfig- Throws:
java.lang.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
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.
-
getWriteSpinCount
public int getWriteSpinCount()
Description copied from interface:ChannelConfigReturns 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:
getWriteSpinCountin interfaceChannelConfig
-
setWriteSpinCount
public ChannelConfig setWriteSpinCount(int writeSpinCount)
Description copied from interface:ChannelConfigSets 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:
setWriteSpinCountin interfaceChannelConfig
-
getAllocator
public ByteBufAllocator getAllocator()
Description copied from interface:ChannelConfigReturnsByteBufAllocatorwhich is used for the channel to allocate buffers.- Specified by:
getAllocatorin interfaceChannelConfig
-
setAllocator
public ChannelConfig setAllocator(ByteBufAllocator allocator)
Description copied from interface:ChannelConfigSet theByteBufAllocatorwhich is used for the channel to allocate buffers.- Specified by:
setAllocatorin interfaceChannelConfig
-
getRecvByteBufAllocator
public <T extends RecvByteBufAllocator> T getRecvByteBufAllocator()
Description copied from interface:ChannelConfigReturnsRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.- Specified by:
getRecvByteBufAllocatorin interfaceChannelConfig
-
setRecvByteBufAllocator
public ChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator)
Description copied from interface:ChannelConfigSet theRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.- Specified by:
setRecvByteBufAllocatorin interfaceChannelConfig
-
isAutoRead
public boolean isAutoRead()
Description copied from interface:ChannelConfigReturnstrueif 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:
isAutoReadin interfaceChannelConfig
-
setAutoRead
public ChannelConfig setAutoRead(boolean autoRead)
Description copied from interface:ChannelConfigSets 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:
setAutoReadin interfaceChannelConfig
-
autoReadCleared
protected void autoReadCleared()
-
isAutoClose
public boolean isAutoClose()
Description copied from interface:ChannelConfigReturnstrueif and only if theChannelwill be closed automatically and immediately on write failure. The default istrue.- Specified by:
isAutoClosein interfaceChannelConfig
-
setAutoClose
public ChannelConfig setAutoClose(boolean autoClose)
Description copied from interface:ChannelConfigSets whether theChannelshould be closed automatically and immediately on write failure. The default istrue.- Specified by:
setAutoClosein interfaceChannelConfig
-
getWriteBufferHighWaterMark
public int getWriteBufferHighWaterMark()
Description copied from interface:ChannelConfigReturns 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:
getWriteBufferHighWaterMarkin interfaceChannelConfig
-
setWriteBufferHighWaterMark
public ChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark)
Description copied from interface:ChannelConfigSets 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:
setWriteBufferHighWaterMarkin interfaceChannelConfig
-
getWriteBufferLowWaterMark
public int getWriteBufferLowWaterMark()
Description copied from interface:ChannelConfigReturns 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.- Specified by:
getWriteBufferLowWaterMarkin interfaceChannelConfig
-
setWriteBufferLowWaterMark
public ChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark)
Description copied from interface:ChannelConfigSets 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.- Specified by:
setWriteBufferLowWaterMarkin interfaceChannelConfig
-
setWriteBufferWaterMark
public ChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark)
Description copied from interface:ChannelConfigSet theWriteBufferWaterMarkwhich is used for setting the high and low water mark of the write buffer.- Specified by:
setWriteBufferWaterMarkin interfaceChannelConfig
-
getWriteBufferWaterMark
public WriteBufferWaterMark getWriteBufferWaterMark()
Description copied from interface:ChannelConfigReturns theWriteBufferWaterMarkwhich is used for setting the high and low water mark of the write buffer.- Specified by:
getWriteBufferWaterMarkin interfaceChannelConfig
-
getMessageSizeEstimator
public MessageSizeEstimator getMessageSizeEstimator()
Description copied from interface:ChannelConfigReturnsMessageSizeEstimatorwhich is used for the channel to detect the size of a message.- Specified by:
getMessageSizeEstimatorin interfaceChannelConfig
-
setMessageSizeEstimator
public ChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator)
Description copied from interface:ChannelConfigSet theMessageSizeEstimatorwhich is used for the channel to detect the size of a message.- Specified by:
setMessageSizeEstimatorin interfaceChannelConfig
-
-