Package org.apache.mina.core.session
Class AbstractIoSessionConfig
- java.lang.Object
-
- org.apache.mina.core.session.AbstractIoSessionConfig
-
- All Implemented Interfaces:
IoSessionConfig
- Direct Known Subclasses:
AbstractDatagramSessionConfig,AbstractSocketSessionConfig,DefaultVmPipeSessionConfig
public abstract class AbstractIoSessionConfig extends java.lang.Object implements IoSessionConfig
A base implementation ofIoSessionConfig.
-
-
Field Summary
Fields Modifier and Type Field Description private intidleTimeForBothThe delay before we notify a session that it has been idle on read and write.private intidleTimeForReadThe delay before we notify a session that it has been idle on read.private intidleTimeForWriteThe delay before we notify a session that it has been idle on write.private intmaxReadBufferSizeThe maximum size of the buffer used to read incoming dataprivate intminReadBufferSizeThe minimum size of the buffer used to read incoming dataprivate intreadBufferSizeThe default size of the buffer used to read incoming dataprivate intthroughputCalculationIntervalprivate booleanuseReadOperationA flag set to true when weallow the application to do a session.read().private intwriteTimeoutThe delay to wait for a write operation to complete before bailing out
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractIoSessionConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetBothIdleTime()longgetBothIdleTimeInMillis()intgetIdleTime(IdleStatus status)longgetIdleTimeInMillis(IdleStatus status)intgetMaxReadBufferSize()intgetMinReadBufferSize()intgetReadBufferSize()intgetReaderIdleTime()longgetReaderIdleTimeInMillis()intgetThroughputCalculationInterval()longgetThroughputCalculationIntervalInMillis()intgetWriterIdleTime()longgetWriterIdleTimeInMillis()intgetWriteTimeout()longgetWriteTimeoutInMillis()booleanisUseReadOperation()voidsetAll(IoSessionConfig config)Sets all configuration properties retrieved from the specifiedconfig.voidsetBothIdleTime(int idleTime)Sets idle time forIdleStatus.WRITER_IDLEin seconds.voidsetIdleTime(IdleStatus status, int idleTime)Sets idle time for the specified type of idleness in seconds.voidsetMaxReadBufferSize(int maxReadBufferSize)Sets the maximum size of the read buffer that I/O processor allocates per each read.voidsetMinReadBufferSize(int minReadBufferSize)Sets the minimum size of the read buffer that I/O processor allocates per each read.voidsetReadBufferSize(int readBufferSize)Sets the size of the read buffer that I/O processor allocates per each read.voidsetReaderIdleTime(int idleTime)Sets idle time forIdleStatus.READER_IDLEin seconds.voidsetThroughputCalculationInterval(int throughputCalculationInterval)Sets the interval (seconds) between each throughput calculation.voidsetUseReadOperation(boolean useReadOperation)Enables or disabledIoSession.read()operation.voidsetWriterIdleTime(int idleTime)Sets idle time forIdleStatus.WRITER_IDLEin seconds.voidsetWriteTimeout(int writeTimeout)Sets write timeout in seconds.
-
-
-
Field Detail
-
minReadBufferSize
private int minReadBufferSize
The minimum size of the buffer used to read incoming data
-
readBufferSize
private int readBufferSize
The default size of the buffer used to read incoming data
-
maxReadBufferSize
private int maxReadBufferSize
The maximum size of the buffer used to read incoming data
-
idleTimeForRead
private int idleTimeForRead
The delay before we notify a session that it has been idle on read. Default to infinite
-
idleTimeForWrite
private int idleTimeForWrite
The delay before we notify a session that it has been idle on write. Default to infinite
-
idleTimeForBoth
private int idleTimeForBoth
The delay before we notify a session that it has been idle on read and write. Default to infinite
-
writeTimeout
private int writeTimeout
The delay to wait for a write operation to complete before bailing out
-
useReadOperation
private boolean useReadOperation
A flag set to true when weallow the application to do a session.read(). Default to false
-
throughputCalculationInterval
private int throughputCalculationInterval
-
-
Method Detail
-
setAll
public void setAll(IoSessionConfig config)
Sets all configuration properties retrieved from the specifiedconfig.- Specified by:
setAllin interfaceIoSessionConfig- Parameters:
config- The configuration to use
-
getReadBufferSize
public int getReadBufferSize()
- Specified by:
getReadBufferSizein interfaceIoSessionConfig- Returns:
- the size of the read buffer that I/O processor allocates per each read. It's unusual to adjust this property because it's often adjusted automatically by the I/O processor.
-
setReadBufferSize
public void setReadBufferSize(int readBufferSize)
Sets the size of the read buffer that I/O processor allocates per each read. It's unusual to adjust this property because it's often adjusted automatically by the I/O processor.- Specified by:
setReadBufferSizein interfaceIoSessionConfig- Parameters:
readBufferSize- The size of the read buffer
-
getMinReadBufferSize
public int getMinReadBufferSize()
- Specified by:
getMinReadBufferSizein interfaceIoSessionConfig- Returns:
- the minimum size of the read buffer that I/O processor allocates per each read. I/O processor will not decrease the read buffer size to the smaller value than this property value.
-
setMinReadBufferSize
public void setMinReadBufferSize(int minReadBufferSize)
Sets the minimum size of the read buffer that I/O processor allocates per each read. I/O processor will not decrease the read buffer size to the smaller value than this property value.- Specified by:
setMinReadBufferSizein interfaceIoSessionConfig- Parameters:
minReadBufferSize- The minimum size of the read buffer
-
getMaxReadBufferSize
public int getMaxReadBufferSize()
- Specified by:
getMaxReadBufferSizein interfaceIoSessionConfig- Returns:
- the maximum size of the read buffer that I/O processor allocates per each read. I/O processor will not increase the read buffer size to the greater value than this property value.
-
setMaxReadBufferSize
public void setMaxReadBufferSize(int maxReadBufferSize)
Sets the maximum size of the read buffer that I/O processor allocates per each read. I/O processor will not increase the read buffer size to the greater value than this property value.- Specified by:
setMaxReadBufferSizein interfaceIoSessionConfig- Parameters:
maxReadBufferSize- The maximum size of the read buffer
-
getIdleTime
public int getIdleTime(IdleStatus status)
- Specified by:
getIdleTimein interfaceIoSessionConfig- Parameters:
status- The status for which we want the idle time (One of READER_IDLE, WRITER_IDLE or BOTH_IDLE)- Returns:
- idle time for the specified type of idleness in seconds.
-
getIdleTimeInMillis
public long getIdleTimeInMillis(IdleStatus status)
- Specified by:
getIdleTimeInMillisin interfaceIoSessionConfig- Parameters:
status- The status for which we want the idle time (One of READER_IDLE, WRITER_IDLE or BOTH_IDLE)- Returns:
- idle time for the specified type of idleness in milliseconds.
-
setIdleTime
public void setIdleTime(IdleStatus status, int idleTime)
Sets idle time for the specified type of idleness in seconds.- Specified by:
setIdleTimein interfaceIoSessionConfig- Parameters:
status- The status for which we want to set the idle time (One of READER_IDLE, WRITER_IDLE or BOTH_IDLE)idleTime- The time in second to set
-
getBothIdleTime
public final int getBothIdleTime()
- Specified by:
getBothIdleTimein interfaceIoSessionConfig- Returns:
- idle time for
IdleStatus.BOTH_IDLEin seconds.
-
getBothIdleTimeInMillis
public final long getBothIdleTimeInMillis()
- Specified by:
getBothIdleTimeInMillisin interfaceIoSessionConfig- Returns:
- idle time for
IdleStatus.BOTH_IDLEin milliseconds.
-
getReaderIdleTime
public final int getReaderIdleTime()
- Specified by:
getReaderIdleTimein interfaceIoSessionConfig- Returns:
- idle time for
IdleStatus.READER_IDLEin seconds.
-
getReaderIdleTimeInMillis
public final long getReaderIdleTimeInMillis()
- Specified by:
getReaderIdleTimeInMillisin interfaceIoSessionConfig- Returns:
- idle time for
IdleStatus.READER_IDLEin milliseconds.
-
getWriterIdleTime
public final int getWriterIdleTime()
- Specified by:
getWriterIdleTimein interfaceIoSessionConfig- Returns:
- idle time for
IdleStatus.WRITER_IDLEin seconds.
-
getWriterIdleTimeInMillis
public final long getWriterIdleTimeInMillis()
- Specified by:
getWriterIdleTimeInMillisin interfaceIoSessionConfig- Returns:
- idle time for
IdleStatus.WRITER_IDLEin milliseconds.
-
setBothIdleTime
public void setBothIdleTime(int idleTime)
Sets idle time forIdleStatus.WRITER_IDLEin seconds.- Specified by:
setBothIdleTimein interfaceIoSessionConfig- Parameters:
idleTime- The time to set
-
setReaderIdleTime
public void setReaderIdleTime(int idleTime)
Sets idle time forIdleStatus.READER_IDLEin seconds.- Specified by:
setReaderIdleTimein interfaceIoSessionConfig- Parameters:
idleTime- The time to set
-
setWriterIdleTime
public void setWriterIdleTime(int idleTime)
Sets idle time forIdleStatus.WRITER_IDLEin seconds.- Specified by:
setWriterIdleTimein interfaceIoSessionConfig- Parameters:
idleTime- The time to set
-
getWriteTimeout
public int getWriteTimeout()
- Specified by:
getWriteTimeoutin interfaceIoSessionConfig- Returns:
- write timeout in seconds.
-
getWriteTimeoutInMillis
public long getWriteTimeoutInMillis()
- Specified by:
getWriteTimeoutInMillisin interfaceIoSessionConfig- Returns:
- write timeout in milliseconds.
-
setWriteTimeout
public void setWriteTimeout(int writeTimeout)
Sets write timeout in seconds.- Specified by:
setWriteTimeoutin interfaceIoSessionConfig- Parameters:
writeTimeout- The timeout to set
-
isUseReadOperation
public boolean isUseReadOperation()
- Specified by:
isUseReadOperationin interfaceIoSessionConfig- Returns:
trueif and only ifIoSession.read()operation is enabled. If enabled, all received messages are stored in an internalBlockingQueueso you can read received messages in more convenient way for client applications. Enabling this option is not useful to server applications and can cause unintended memory leak, and therefore it's disabled by default.
-
setUseReadOperation
public void setUseReadOperation(boolean useReadOperation)
Enables or disabledIoSession.read()operation. If enabled, all received messages are stored in an internalBlockingQueueso you can read received messages in more convenient way for client applications. Enabling this option is not useful to server applications and can cause unintended memory leak, and therefore it's disabled by default.- Specified by:
setUseReadOperationin interfaceIoSessionConfig- Parameters:
useReadOperation-trueif the read operation is enabled,falseotherwise
-
getThroughputCalculationInterval
public int getThroughputCalculationInterval()
- Specified by:
getThroughputCalculationIntervalin interfaceIoSessionConfig- Returns:
- the interval (seconds) between each throughput calculation.
The default value is
3seconds.
-
setThroughputCalculationInterval
public void setThroughputCalculationInterval(int throughputCalculationInterval)
Sets the interval (seconds) between each throughput calculation. The default value is3seconds.- Specified by:
setThroughputCalculationIntervalin interfaceIoSessionConfig- Parameters:
throughputCalculationInterval- The interval
-
getThroughputCalculationIntervalInMillis
public long getThroughputCalculationIntervalInMillis()
- Specified by:
getThroughputCalculationIntervalInMillisin interfaceIoSessionConfig- Returns:
- the interval (milliseconds) between each throughput calculation.
The default value is
3seconds.
-
-