Class DefaultChannelConfig
java.lang.Object
io.netty.channel.DefaultChannelConfig
- All Implemented Interfaces:
ChannelConfig
- Direct Known Subclasses:
DefaultDatagramChannelConfig, DefaultSctpChannelConfig, DefaultSctpServerChannelConfig, DefaultServerSocketChannelConfig, DefaultSocketChannelConfig, DefaultUdtChannelConfig, EpollChannelConfig, KQueueChannelConfig
The default
ChannelConfig implementation.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefaultChannelConfig(Channel channel) protectedDefaultChannelConfig(Channel channel, RecvByteBufAllocator allocator) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidReturnsByteBufAllocatorwhich is used for the channel to allocate buffers.intReturns the connect timeout of the channel in milliseconds.intDeprecated.intGet the maximum number of message to write per eventloop run.ReturnsMessageSizeEstimatorwhich is used for the channel to detect the size of a message.<T> TgetOption(ChannelOption<T> option) Return the value of the givenChannelOptionMap<ChannelOption<?>, Object> Return all setChannelOption's.protected Map<ChannelOption<?>, Object> getOptions(Map<ChannelOption<?>, Object> result, ChannelOption<?>... options) <T extends RecvByteBufAllocator>
TReturnsRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.intReturns the high water mark of the write buffer.intReturns the low water mark of the write buffer.Returns theWriteBufferWaterMarkwhich is used for setting the high and low water mark of the write buffer.intReturns the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)returns a non-zero value.booleanReturnstrueif and only if theChannelwill be closed automatically and immediately on write failure.booleanReturnstrueif 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 theByteBufAllocatorwhich is used for the channel to allocate buffers.setAutoClose(boolean autoClose) Sets whether theChannelshould 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 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(Map<ChannelOption<?>, ?> options) Sets the configuration properties from the specifiedMap.setRecvByteBufAllocator(RecvByteBufAllocator allocator) Set theRecvByteBufAllocatorwhich 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 theWriteBufferWaterMarkwhich 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> voidvalidate(ChannelOption<T> option, T value)
-
Field Details
-
channel
-
-
Constructor Details
-
DefaultChannelConfig
-
DefaultChannelConfig
-
-
Method Details
-
getOptions
Description copied from interface:ChannelConfigReturn all setChannelOption's.- Specified by:
getOptionsin interfaceChannelConfig
-
getOptions
protected Map<ChannelOption<?>, Object> getOptions(Map<ChannelOption<?>, Object> result, ChannelOption<?>... options) -
setOptions
Description copied from interface:ChannelConfigSets the configuration properties from the specifiedMap.- Specified by:
setOptionsin interfaceChannelConfig
-
getOption
Description copied from interface:ChannelConfigReturn the value of the givenChannelOption- Specified by:
getOptionin interfaceChannelConfig
-
setOption
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
-
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
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.- Specified by:
getMaxMessagesPerReadin interfaceChannelConfig- Throws:
IllegalStateException- ifgetRecvByteBufAllocator()does not return an object of typeMaxMessagesRecvByteBufAllocator.
-
setMaxMessagesPerRead
Deprecated.- Specified by:
setMaxMessagesPerReadin 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: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
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
Description copied from interface:ChannelConfigReturnsByteBufAllocatorwhich is used for the channel to allocate buffers.- Specified by:
getAllocatorin interfaceChannelConfig
-
setAllocator
Description copied from interface:ChannelConfigSet theByteBufAllocatorwhich is used for the channel to allocate buffers.- Specified by:
setAllocatorin interfaceChannelConfig
-
getRecvByteBufAllocator
Description copied from interface:ChannelConfigReturnsRecvByteBufAllocatorwhich is used for the channel to allocate receive buffers.- Specified by:
getRecvByteBufAllocatorin interfaceChannelConfig
-
setRecvByteBufAllocator
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
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
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
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
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
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
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
Description copied from interface:ChannelConfigReturnsMessageSizeEstimatorwhich is used for the channel to detect the size of a message.- Specified by:
getMessageSizeEstimatorin interfaceChannelConfig
-
setMessageSizeEstimator
Description copied from interface:ChannelConfigSet theMessageSizeEstimatorwhich is used for the channel to detect the size of a message.- Specified by:
setMessageSizeEstimatorin interfaceChannelConfig
-