Class DefaultNioSocketChannelConfig
java.lang.Object
org.jboss.netty.channel.DefaultChannelConfig
org.jboss.netty.channel.socket.DefaultSocketChannelConfig
org.jboss.netty.channel.socket.nio.DefaultNioSocketChannelConfig
- All Implemented Interfaces:
ChannelConfig
,NioChannelConfig
,NioSocketChannelConfig
,SocketChannelConfig
class DefaultNioSocketChannelConfig
extends DefaultSocketChannelConfig
implements NioSocketChannelConfig
The default
NioSocketChannelConfig
implementation.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ReceiveBufferSizePredictorFactory
private static final InternalLogger
private ReceiveBufferSizePredictor
private int
private int
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns theReceiveBufferSizePredictor
which predicts the number of readable bytes in the socket receive buffer.Returns theReceiveBufferSizePredictorFactory
which creates a newReceiveBufferSizePredictor
when a new channel is created and noReceiveBufferSizePredictor
was set.int
Returns the high water mark of the write buffer.int
Returns the 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
Sets a configuration property with the specified name and value.void
setOptions
(Map<String, Object> options) Sets the configuration properties from the specifiedMap
.void
Sets theReceiveBufferSizePredictor
which predicts the number of readable bytes in the socket receive buffer.void
setReceiveBufferSizePredictorFactory
(ReceiveBufferSizePredictorFactory predictorFactory) Sets theReceiveBufferSizePredictor
which creates a newReceiveBufferSizePredictor
when a new channel is created and noReceiveBufferSizePredictor
was set.void
setWriteBufferHighWaterMark
(int writeBufferHighWaterMark) Sets the high water mark of the write buffer.private void
setWriteBufferHighWaterMark0
(int writeBufferHighWaterMark) void
setWriteBufferLowWaterMark
(int writeBufferLowWaterMark) Sets the low water mark of the write buffer.private void
setWriteBufferLowWaterMark0
(int writeBufferLowWaterMark) void
setWriteSpinCount
(int writeSpinCount) Sets the maximum loop count for a write operation untilWritableByteChannel.write(ByteBuffer)
returns a non-zero value.Methods inherited from class org.jboss.netty.channel.socket.DefaultSocketChannelConfig
getReceiveBufferSize, getSendBufferSize, getSoLinger, getTrafficClass, isKeepAlive, isReuseAddress, isTcpNoDelay, setKeepAlive, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoLinger, setTcpNoDelay, setTrafficClass
Methods inherited from class org.jboss.netty.channel.DefaultChannelConfig
getBufferFactory, getConnectTimeoutMillis, getPipelineFactory, setBufferFactory, setConnectTimeoutMillis, setPipelineFactory
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jboss.netty.channel.ChannelConfig
getBufferFactory, getConnectTimeoutMillis, getPipelineFactory, setBufferFactory, setConnectTimeoutMillis, setPipelineFactory
Methods inherited from interface org.jboss.netty.channel.socket.SocketChannelConfig
getReceiveBufferSize, getSendBufferSize, getSoLinger, getTrafficClass, isKeepAlive, isReuseAddress, isTcpNoDelay, setKeepAlive, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoLinger, setTcpNoDelay, setTrafficClass
-
Field Details
-
logger
-
DEFAULT_PREDICTOR_FACTORY
-
writeBufferHighWaterMark
private volatile int writeBufferHighWaterMark -
writeBufferLowWaterMark
private volatile int writeBufferLowWaterMark -
predictor
-
predictorFactory
-
writeSpinCount
private volatile int writeSpinCount
-
-
Constructor Details
-
DefaultNioSocketChannelConfig
DefaultNioSocketChannelConfig(Socket socket)
-
-
Method Details
-
setOptions
Description copied from interface:ChannelConfig
Sets the configuration properties from the specifiedMap
.- Specified by:
setOptions
in interfaceChannelConfig
- Overrides:
setOptions
in classDefaultChannelConfig
-
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(String name, Object value) { if (super.setOption(name, value)) { return true; } if (name.equals("additionalOption")) { .... return true; } return false; }
- Specified by:
setOption
in interfaceChannelConfig
- Overrides:
setOption
in classDefaultSocketChannelConfig
- Returns:
true
if and only if the property has been set
-
getWriteBufferHighWaterMark
public int getWriteBufferHighWaterMark()Description copied from interface:NioChannelConfig
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 interfaceNioChannelConfig
-
setWriteBufferHighWaterMark
public void setWriteBufferHighWaterMark(int writeBufferHighWaterMark) Description copied from interface:NioChannelConfig
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 interfaceNioChannelConfig
-
setWriteBufferHighWaterMark0
private void setWriteBufferHighWaterMark0(int writeBufferHighWaterMark) -
getWriteBufferLowWaterMark
public int getWriteBufferLowWaterMark()Description copied from interface:NioChannelConfig
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 interfaceNioChannelConfig
-
setWriteBufferLowWaterMark
public void setWriteBufferLowWaterMark(int writeBufferLowWaterMark) Description copied from interface:NioChannelConfig
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 toreturntrue
again.- Specified by:
setWriteBufferLowWaterMark
in interfaceNioChannelConfig
-
setWriteBufferLowWaterMark0
private void setWriteBufferLowWaterMark0(int writeBufferLowWaterMark) -
getWriteSpinCount
public int getWriteSpinCount()Description copied from interface:NioChannelConfig
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 interfaceNioChannelConfig
-
setWriteSpinCount
public void setWriteSpinCount(int writeSpinCount) Description copied from interface:NioChannelConfig
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 interfaceNioChannelConfig
-
getReceiveBufferSizePredictor
Description copied from interface:NioSocketChannelConfig
Returns theReceiveBufferSizePredictor
which predicts the number of readable bytes in the socket receive buffer. The default predictor isAdaptiveReceiveBufferSizePredictor
(64, 1024, 65536).- Specified by:
getReceiveBufferSizePredictor
in interfaceNioSocketChannelConfig
-
setReceiveBufferSizePredictor
Description copied from interface:NioSocketChannelConfig
Sets theReceiveBufferSizePredictor
which predicts the number of readable bytes in the socket receive buffer. The default predictor isAdaptiveReceiveBufferSizePredictor
(64, 1024, 65536).- Specified by:
setReceiveBufferSizePredictor
in interfaceNioSocketChannelConfig
-
getReceiveBufferSizePredictorFactory
Description copied from interface:NioSocketChannelConfig
Returns theReceiveBufferSizePredictorFactory
which creates a newReceiveBufferSizePredictor
when a new channel is created and noReceiveBufferSizePredictor
was set. If no predictor was set for the channel,NioSocketChannelConfig.setReceiveBufferSizePredictor(ReceiveBufferSizePredictor)
will be called with the new predictor. The default factory isAdaptiveReceiveBufferSizePredictorFactory
(64, 1024, 65536).- Specified by:
getReceiveBufferSizePredictorFactory
in interfaceNioSocketChannelConfig
-
setReceiveBufferSizePredictorFactory
public void setReceiveBufferSizePredictorFactory(ReceiveBufferSizePredictorFactory predictorFactory) Description copied from interface:NioSocketChannelConfig
Sets theReceiveBufferSizePredictor
which creates a newReceiveBufferSizePredictor
when a new channel is created and noReceiveBufferSizePredictor
was set. If no predictor was set for the channel,NioSocketChannelConfig.setReceiveBufferSizePredictor(ReceiveBufferSizePredictor)
will be called with the new predictor. The default factory isAdaptiveReceiveBufferSizePredictorFactory
(64, 1024, 65536).- Specified by:
setReceiveBufferSizePredictorFactory
in interfaceNioSocketChannelConfig
-