Class AbstractIoSession
java.lang.Object
org.apache.mina.core.session.AbstractIoSession
- All Implemented Interfaces:
IoSession
- Direct Known Subclasses:
AprSession, DummySession, NioSession, VmPipeSession
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IoSessionAttributeMapstatic final WriteRequestAn internal write request object that triggers session close.private final CloseFutureA future that will be set 'closed' when the connection is closed.private booleanprotected IoSessionConfigThe session configprivate final longThe Session creation's timeprivate WriteRequestprivate booleanprivate final IoHandlerThe associated handlerprivate static AtomicLongAn id generator guaranteed to generate unique IDs for the sessionprivate AtomicIntegerprivate AtomicIntegerprivate AtomicIntegerprivate longprivate longprivate longprivate longprivate longprivate longprivate longprivate longprivate longprivate longprivate final Objectstatic final WriteRequestAn internal write request object that triggers message sent events.private longprivate doubleprivate longprivate doubleprivate booleanprivate static final AttributeKeyprivate static final IoFutureListener<CloseFuture> private final AtomicBooleanprivate final AtomicIntegerprivate final AtomicIntegerprivate final IoServiceThe service which will manage this sessionprivate longThe session IDprivate static final AttributeKeyprivate WriteRequestQueueprivate booleanprivate longprivate doubleprivate longprivate double -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractIoSession(IoService service) Create a Session for a service -
Method Summary
Modifier and TypeMethodDescriptionfinal CloseFutureclose()Closes this session after all queued write requests are flushed.final CloseFutureclose(boolean rightNow) Closes this session immediately or after all queued write requests are flushed.final CloseFuturecloseNow()Closes this session immediately.final CloseFutureCloses this session after all queued write requests are flushed.final booleancontainsAttribute(Object key) final voidDecrease the ReadBuffer size (it will be divided by a factor 2)final voidDecrease the counters of written messages and written bytes when a message has been writtenprivate voidDecrease the number of scheduled message writtenprotected voiddestroy()Destroy the sessionfinal booleanTODO This is a ridiculous implementation.final ObjectReturns an attachment of this session.final ObjectgetAttribute(Object key) Returns the value of the user-defined attribute of this session.final ObjectgetAttribute(Object key, Object defaultValue) Returns the value of user defined attribute associated with the specified key.final IoSessionAttributeMapfinal intfinal CloseFuturefinal longfinal ObjectReturns the message which is being written byIoService.final WriteRequestReturns theWriteRequestwhich is being processed byIoService.final longgetId()We use an AtomicLong to guarantee that the session ID are unique.private StringGet the Id as a Stringfinal intgetIdleCount(IdleStatus status) final longfinal longgetLastIdleTime(IdleStatus status) final longfinal longfinal longfinal longfinal longabstract IoProcessorfinal longfinal doublefinal intfinal longfinal doubleprivate Queue<ReadFuture> final longfinal intprivate StringTGet the Service nameprivate Queue<ReadFuture> final WriteRequestQueueGet the queue that contains the message waiting for being written.final intfinal longfinal doublefinal longfinal doublefinal inthashCode()final voidincreaseIdleCount(IdleStatus status, long currentTime) Increase the count of the various Idle counterfinal voidIncrease the ReadBuffer size (it will double)final voidincreaseReadBytes(long increment, long currentTime) Increase the number of read bytesfinal voidincreaseReadMessages(long currentTime) Increase the number of read messagesfinal voidincreaseScheduledWriteBytes(int increment) Increase the number of scheduled write bytes for the sessionfinal voidIncrease the number of scheduled message to writefinal voidincreaseWrittenBytes(int increment, long currentTime) Increase the number of written bytesfinal voidincreaseWrittenMessages(WriteRequest request, long currentTime) Increase the number of written messagesbooleanisActive()final booleanfinal booleanfinal booleanfinal booleanisIdle(IdleStatus status) final booleanbooleanIs read operation is suspended for this session.final booleanTells if the session is scheduled for flushedbooleanfinal booleanbooleanIs write operation is suspended for this session.private ReadFuturestatic voidnotifyIdleness(Iterator<? extends IoSession> sessions, long currentTime) Fires aIoEventType.SESSION_IDLEevent to any applicable sessions in the specified collection.static voidnotifyIdleSession(IoSession session, long currentTime) Fires aIoEventType.SESSION_IDLEevent if applicable for the specifiedsession.private static voidnotifyIdleSession0(IoSession session, long currentTime, long idleTime, IdleStatus status, long lastIoTime) private static voidnotifyWriteTimeout(IoSession session, long currentTime) final voidInform the ReadFuture that the session has been closedfinal voidofferFailedReadFuture(Throwable exception) Associates a failure to a ReadFuturefinal voidofferReadFuture(Object message) Associates a message to a ReadFuturefinal ReadFutureread()TODO This javadoc is wrong.final ObjectremoveAttribute(Object key) Removes a user-defined attribute with the specified key.final booleanremoveAttribute(Object key, Object value) Removes a user defined attribute with the specified key if the current attribute value is equal to the specified value.final booleanreplaceAttribute(Object key, Object oldValue, Object newValue) Replaces a user defined attribute with the specified key if the value of the attribute is equals to the specified old value.final voidResumes read operations for this session.final voidResumes write operations for this session.final voidSchedule the session for flushedfinal ObjectsetAttachment(Object attachment) Sets an attachment of this session.final ObjectsetAttribute(Object key) Sets a user defined attribute without a value.final ObjectsetAttribute(Object key, Object value) Sets a user-defined attribute.final ObjectSets a user defined attribute without a value if the attribute with the specified key is not set yet.final ObjectsetAttributeIfAbsent(Object key, Object value) Sets a user defined attribute if the attribute with the specified key is not set yet.final voidsetAttributeMap(IoSessionAttributeMap attributes) Set the map of attributes associated with the sessionfinal voidsetCurrentWriteRequest(WriteRequest currentWriteRequest) Associate the current write request with the sessionfinal booleansetScheduledForFlush(boolean schedule) Set the scheduledForFLush flag.protected voidsetScheduledWriteBytes(int byteCount) Set the number of scheduled write bytesprotected voidsetScheduledWriteMessages(int messages) Set the number of scheduled write messagesfinal voidsetWriteRequestQueue(WriteRequestQueue writeRequestQueue) Create a new close aware write queue, based on the given write queue.final voidSuspends read operations for this session.final voidSuspends write operations for this session.toString()final voidChange the session's status : it's not anymore scheduled for flushfinal voidupdateThroughput(long currentTime, boolean force) Update all statistical properties related with throughput assuming the specified time is the current time.Writes the specifiedmessageto remote peer.write(Object message, SocketAddress remoteAddress) (Optional) Writes the specifiedmessageto the specifieddestination.Methods inherited from interface IoSession
getFilterChain, getLocalAddress, getRemoteAddress, getTransportMetadata
-
Field Details
-
handler
The associated handler -
config
The session config -
service
The service which will manage this session -
READY_READ_FUTURES_KEY
-
WAITING_READ_FUTURES_KEY
-
SCHEDULED_COUNTER_RESETTER
-
CLOSE_REQUEST
An internal write request object that triggers session close. -
MESSAGE_SENT_REQUEST
An internal write request object that triggers message sent events. -
lock
-
attributes
-
writeRequestQueue
-
currentWriteRequest
-
creationTime
private final long creationTimeThe Session creation's time -
idGenerator
An id generator guaranteed to generate unique IDs for the session -
sessionId
private long sessionIdThe session ID -
closeFuture
A future that will be set 'closed' when the connection is closed. -
closing
private volatile boolean closing -
readSuspended
private boolean readSuspended -
writeSuspended
private boolean writeSuspended -
scheduledForFlush
-
scheduledWriteBytes
-
scheduledWriteMessages
-
readBytes
private long readBytes -
writtenBytes
private long writtenBytes -
readMessages
private long readMessages -
writtenMessages
private long writtenMessages -
lastReadTime
private long lastReadTime -
lastWriteTime
private long lastWriteTime -
lastThroughputCalculationTime
private long lastThroughputCalculationTime -
lastReadBytes
private long lastReadBytes -
lastWrittenBytes
private long lastWrittenBytes -
lastReadMessages
private long lastReadMessages -
lastWrittenMessages
private long lastWrittenMessages -
readBytesThroughput
private double readBytesThroughput -
writtenBytesThroughput
private double writtenBytesThroughput -
readMessagesThroughput
private double readMessagesThroughput -
writtenMessagesThroughput
private double writtenMessagesThroughput -
idleCountForBoth
-
idleCountForRead
-
idleCountForWrite
-
lastIdleTimeForBoth
private long lastIdleTimeForBoth -
lastIdleTimeForRead
private long lastIdleTimeForRead -
lastIdleTimeForWrite
private long lastIdleTimeForWrite -
deferDecreaseReadBuffer
private boolean deferDecreaseReadBuffer
-
-
Constructor Details
-
AbstractIoSession
Create a Session for a service- Parameters:
service- the Service for this session
-
-
Method Details
-
getId
public final long getId()We use an AtomicLong to guarantee that the session ID are unique.- Specified by:
getIdin interfaceIoSession- Returns:
- a unique identifier for this session. Every session has its own ID which is different from each other. TODO : The way it's implemented does not guarantee that the contract is respected. It uses the HashCode() method which don't guarantee the key unicity.
-
getProcessor
- Returns:
- The associated IoProcessor for this session
-
isConnected
public final boolean isConnected()- Specified by:
isConnectedin interfaceIoSession- Returns:
trueif this session is connected with remote peer.
-
isActive
-
isClosing
-
isSecured
-
getCloseFuture
- Specified by:
getCloseFuturein interfaceIoSession- Returns:
- the
CloseFutureof this session. This method returns the same instance whenever user calls it.
-
isScheduledForFlush
public final boolean isScheduledForFlush()Tells if the session is scheduled for flushed- Returns:
- true if the session is scheduled for flush
-
scheduledForFlush
public final void scheduledForFlush()Schedule the session for flushed -
unscheduledForFlush
public final void unscheduledForFlush()Change the session's status : it's not anymore scheduled for flush -
setScheduledForFlush
public final boolean setScheduledForFlush(boolean schedule) Set the scheduledForFLush flag. As we may have concurrent access to this flag, we compare and set it in one call.- Parameters:
schedule- the new value to set if not already set.- Returns:
- true if the session flag has been set, and if it wasn't set already.
-
close
Closes this session immediately or after all queued write requests are flushed. This operation is asynchronous. Wait for the returnedCloseFutureif you want to wait for the session actually closed. -
close
Closes this session after all queued write requests are flushed. This operation is asynchronous. Wait for the returnedCloseFutureif you want to wait for the session actually closed. -
closeOnFlush
Closes this session after all queued write requests are flushed. This operation is asynchronous. Wait for the returnedCloseFutureif you want to wait for the session actually closed.- Specified by:
closeOnFlushin interfaceIoSession- Returns:
- The associated CloseFuture
-
closeNow
Closes this session immediately. This operation is asynchronous, it returns aCloseFuture.- Specified by:
closeNowin interfaceIoSession- Returns:
- The
CloseFuturethat can be use to wait for the completion of this operation
-
destroy
protected void destroy()Destroy the session -
getHandler
- Specified by:
getHandlerin interfaceIoSession- Returns:
- the
IoHandlerwhich handles this session.
-
getConfig
-
read
TODO This javadoc is wrong. The return tag should be short.- Specified by:
readin interfaceIoSession- Returns:
- a
ReadFuturewhich is notified when a new message is received, the connection is closed or an exception is caught. This operation is especially useful when you implement a client application. TODO : Describe here how we enable this feature. However, please note that this operation is disabled by default and throwIllegalStateExceptionbecause all received events must be queued somewhere to support this operation, possibly leading to memory leak. This means you have to keep callingIoSession.read()once you enabled this operation. To enable this operation, please callIoSessionConfig.setUseReadOperation(boolean)withtrue.
-
offerReadFuture
Associates a message to a ReadFuture- Parameters:
message- the message to associate to the ReadFuture
-
offerFailedReadFuture
Associates a failure to a ReadFuture- Parameters:
exception- the exception to associate to the ReadFuture
-
offerClosedReadFuture
public final void offerClosedReadFuture()Inform the ReadFuture that the session has been closed -
newReadFuture
- Returns:
- a readFuture get from the waiting ReadFuture
-
getReadyReadFutures
- Returns:
- a queue of ReadFuture
-
getWaitingReadFutures
- Returns:
- the queue of waiting ReadFuture
-
write
Writes the specifiedmessageto remote peer. This operation is asynchronous;IoHandler.messageSent(IoSession,Object)will be invoked when the message is actually sent to remote peer. You can also wait for the returnedWriteFutureif you want to wait for the message actually written. -
write
(Optional) Writes the specifiedmessageto the specifieddestination. This operation is asynchronous;IoHandler.messageSent(IoSession, Object)will be invoked when the message is actually sent to remote peer. You can also wait for the returnedWriteFutureif you want to wait for the message actually written.When you implement a client that receives a broadcast message from a server such as DHCP server, the client might need to send a response message for the broadcast message the server sent. Because the remote address of the session is not the address of the server in case of broadcasting, there should be a way to specify the destination when you write the response message. This interface provides
IoSession.write(Object, SocketAddress)method so you can specify the destination. -
getAttachment
Returns an attachment of this session. This method is identical withgetAttribute( "" ).- Specified by:
getAttachmentin interfaceIoSession- Returns:
- The attachment
-
setAttachment
Sets an attachment of this session. This method is identical withsetAttribute( "", attachment ).- Specified by:
setAttachmentin interfaceIoSession- Parameters:
attachment- The attachment- Returns:
- Old attachment.
nullif it is new.
-
getAttribute
Returns the value of the user-defined attribute of this session.- Specified by:
getAttributein interfaceIoSession- Parameters:
key- the key of the attribute- Returns:
nullif there is no attribute with the specified key
-
getAttribute
Returns the value of user defined attribute associated with the specified key. If there's no such attribute, the specified default value is associated with the specified key, and the default value is returned. This method is same with the following code except that the operation is performed atomically.if (containsAttribute(key)) { return getAttribute(key); } else { setAttribute(key, defaultValue); return defaultValue; }- Specified by:
getAttributein interfaceIoSession- Parameters:
key- the key of the attribute we want to retreivedefaultValue- the default value of the attribute- Returns:
- The retrieved attribute or
nullif not found
-
setAttribute
Sets a user-defined attribute.- Specified by:
setAttributein interfaceIoSession- Parameters:
key- the key of the attributevalue- the value of the attribute- Returns:
- The old value of the attribute.
nullif it is new.
-
setAttribute
Sets a user defined attribute without a value. This is useful when you just want to put a 'mark' attribute. Its value is set toBoolean.TRUE.- Specified by:
setAttributein interfaceIoSession- Parameters:
key- the key of the attribute- Returns:
- The old value of the attribute.
nullif it is new.
-
setAttributeIfAbsent
Sets a user defined attribute if the attribute with the specified key is not set yet. This method is same with the following code except that the operation is performed atomically.if (containsAttribute(key)) { return getAttribute(key); } else { return setAttribute(key, value); }- Specified by:
setAttributeIfAbsentin interfaceIoSession- Parameters:
key- The key of the attribute we want to setvalue- The value we want to set- Returns:
- The old value of the attribute.
nullif not found.
-
setAttributeIfAbsent
Sets a user defined attribute without a value if the attribute with the specified key is not set yet. This is useful when you just want to put a 'mark' attribute. Its value is set toBoolean.TRUE. This method is same with the following code except that the operation is performed atomically.if (containsAttribute(key)) { return getAttribute(key); // might not always be Boolean.TRUE. } else { return setAttribute(key); }- Specified by:
setAttributeIfAbsentin interfaceIoSession- Parameters:
key- The key of the attribute we want to set- Returns:
- The old value of the attribute.
nullif not found.
-
removeAttribute
Removes a user-defined attribute with the specified key.- Specified by:
removeAttributein interfaceIoSession- Parameters:
key- The key of the attribute we want to remove- Returns:
- The old value of the attribute.
nullif not found.
-
removeAttribute
Removes a user defined attribute with the specified key if the current attribute value is equal to the specified value. This method is same with the following code except that the operation is performed atomically.if (containsAttribute(key) && getAttribute(key).equals(value)) { removeAttribute(key); return true; } else { return false; }- Specified by:
removeAttributein interfaceIoSession- Parameters:
key- The key we want to removevalue- The value we want to remove- Returns:
trueif the removal was successful
-
replaceAttribute
Replaces a user defined attribute with the specified key if the value of the attribute is equals to the specified old value. This method is same with the following code except that the operation is performed atomically.if (containsAttribute(key) && getAttribute(key).equals(oldValue)) { setAttribute(key, newValue); return true; } else { return false; }- Specified by:
replaceAttributein interfaceIoSession- Parameters:
key- The key we want to replaceoldValue- The previous valuenewValue- The new value- Returns:
trueif the replacement was successful
-
containsAttribute
- Specified by:
containsAttributein interfaceIoSession- Parameters:
key- The key of the attribute we are looking for in the session- Returns:
trueif this session contains the attribute with the specifiedkey.
-
getAttributeKeys
- Specified by:
getAttributeKeysin interfaceIoSession- Returns:
- the set of keys of all user-defined attributes.
-
getAttributeMap
- Returns:
- The map of attributes associated with the session
-
setAttributeMap
Set the map of attributes associated with the session- Parameters:
attributes- The Map of attributes
-
setWriteRequestQueue
Create a new close aware write queue, based on the given write queue.- Parameters:
writeRequestQueue- The write request queue
-
suspendRead
public final void suspendRead()Suspends read operations for this session.- Specified by:
suspendReadin interfaceIoSession
-
suspendWrite
public final void suspendWrite()Suspends write operations for this session.- Specified by:
suspendWritein interfaceIoSession
-
resumeRead
public final void resumeRead()Resumes read operations for this session.- Specified by:
resumeReadin interfaceIoSession
-
resumeWrite
public final void resumeWrite()Resumes write operations for this session.- Specified by:
resumeWritein interfaceIoSession
-
isReadSuspended
public boolean isReadSuspended()Is read operation is suspended for this session.- Specified by:
isReadSuspendedin interfaceIoSession- Returns:
trueif suspended
-
isWriteSuspended
public boolean isWriteSuspended()Is write operation is suspended for this session.- Specified by:
isWriteSuspendedin interfaceIoSession- Returns:
trueif suspended
-
getReadBytes
public final long getReadBytes()- Specified by:
getReadBytesin interfaceIoSession- Returns:
- the total number of bytes which were read from this session.
-
getWrittenBytes
public final long getWrittenBytes()- Specified by:
getWrittenBytesin interfaceIoSession- Returns:
- the total number of bytes which were written to this session.
-
getReadMessages
public final long getReadMessages()- Specified by:
getReadMessagesin interfaceIoSession- Returns:
- the total number of messages which were read and decoded from this session.
-
getWrittenMessages
public final long getWrittenMessages()- Specified by:
getWrittenMessagesin interfaceIoSession- Returns:
- the total number of messages which were written and encoded by this session.
-
getReadBytesThroughput
public final double getReadBytesThroughput()- Specified by:
getReadBytesThroughputin interfaceIoSession- Returns:
- the number of read bytes per second.
-
getWrittenBytesThroughput
public final double getWrittenBytesThroughput()- Specified by:
getWrittenBytesThroughputin interfaceIoSession- Returns:
- the number of written bytes per second.
-
getReadMessagesThroughput
public final double getReadMessagesThroughput()- Specified by:
getReadMessagesThroughputin interfaceIoSession- Returns:
- the number of read messages per second.
-
getWrittenMessagesThroughput
public final double getWrittenMessagesThroughput()- Specified by:
getWrittenMessagesThroughputin interfaceIoSession- Returns:
- the number of written messages per second.
-
updateThroughput
public final void updateThroughput(long currentTime, boolean force) Update all statistical properties related with throughput assuming the specified time is the current time. By default this method returns silently without updating the throughput properties if they were calculated already within lastcalculation interval. If, however,forceis specified astrue, this method updates the throughput properties immediately.- Specified by:
updateThroughputin interfaceIoSession- Parameters:
currentTime- the current time in millisecondsforce- Force the update iftrue
-
getScheduledWriteBytes
public final long getScheduledWriteBytes()- Specified by:
getScheduledWriteBytesin interfaceIoSession- Returns:
- the number of bytes which are scheduled to be written to this session.
-
getScheduledWriteMessages
public final int getScheduledWriteMessages()- Specified by:
getScheduledWriteMessagesin interfaceIoSession- Returns:
- the number of messages which are scheduled to be written to this session.
-
setScheduledWriteBytes
protected void setScheduledWriteBytes(int byteCount) Set the number of scheduled write bytes- Parameters:
byteCount- The number of scheduled bytes for write
-
setScheduledWriteMessages
protected void setScheduledWriteMessages(int messages) Set the number of scheduled write messages- Parameters:
messages- The number of scheduled messages for write
-
increaseReadBytes
public final void increaseReadBytes(long increment, long currentTime) Increase the number of read bytes- Parameters:
increment- The number of read bytescurrentTime- The current time
-
increaseReadMessages
public final void increaseReadMessages(long currentTime) Increase the number of read messages- Parameters:
currentTime- The current time
-
increaseWrittenBytes
public final void increaseWrittenBytes(int increment, long currentTime) Increase the number of written bytes- Parameters:
increment- The number of written bytescurrentTime- The current time
-
increaseWrittenMessages
Increase the number of written messages- Parameters:
request- The written messagecurrentTime- The current tile
-
increaseScheduledWriteBytes
public final void increaseScheduledWriteBytes(int increment) Increase the number of scheduled write bytes for the session- Parameters:
increment- The number of newly added bytes to write
-
increaseScheduledWriteMessages
public final void increaseScheduledWriteMessages()Increase the number of scheduled message to write -
decreaseScheduledWriteMessages
private void decreaseScheduledWriteMessages()Decrease the number of scheduled message written -
decreaseScheduledBytesAndMessages
Decrease the counters of written messages and written bytes when a message has been written- Parameters:
request- The written message
-
getWriteRequestQueue
Get the queue that contains the message waiting for being written. As the reader might not be ready, it's frequent that the messages aren't written completely, or that some older messages are waiting to be written when a new message arrives. This queue is used to manage the backlog of messages.- Specified by:
getWriteRequestQueuein interfaceIoSession- Returns:
- The queue containing the pending messages.
-
getCurrentWriteRequest
Returns theWriteRequestwhich is being processed byIoService.- Specified by:
getCurrentWriteRequestin interfaceIoSession- Returns:
nullif and if only no message is being written
-
getCurrentWriteMessage
Returns the message which is being written byIoService.- Specified by:
getCurrentWriteMessagein interfaceIoSession- Returns:
nullif and if only no message is being written
-
setCurrentWriteRequest
Associate the current write request with the session- Specified by:
setCurrentWriteRequestin interfaceIoSession- Parameters:
currentWriteRequest- the current write request to associate
-
increaseReadBufferSize
public final void increaseReadBufferSize()Increase the ReadBuffer size (it will double) -
decreaseReadBufferSize
public final void decreaseReadBufferSize()Decrease the ReadBuffer size (it will be divided by a factor 2) -
getCreationTime
public final long getCreationTime()- Specified by:
getCreationTimein interfaceIoSession- Returns:
- the session's creation time in milliseconds
-
getLastIoTime
public final long getLastIoTime()- Specified by:
getLastIoTimein interfaceIoSession- Returns:
- the time in millis when I/O occurred lastly.
-
getLastReadTime
public final long getLastReadTime()- Specified by:
getLastReadTimein interfaceIoSession- Returns:
- the time in millis when read operation occurred lastly.
-
getLastWriteTime
public final long getLastWriteTime()- Specified by:
getLastWriteTimein interfaceIoSession- Returns:
- the time in millis when write operation occurred lastly.
-
isIdle
- Specified by:
isIdlein interfaceIoSession- Parameters:
status- The researched idle status- Returns:
trueif this session is idle for the specifiedIdleStatus.
-
isBothIdle
public final boolean isBothIdle()- Specified by:
isBothIdlein interfaceIoSession- Returns:
trueif this session isIdleStatus.BOTH_IDLE.- See Also:
-
isReaderIdle
public final boolean isReaderIdle()- Specified by:
isReaderIdlein interfaceIoSession- Returns:
trueif this session isIdleStatus.READER_IDLE.- See Also:
-
isWriterIdle
public final boolean isWriterIdle()- Specified by:
isWriterIdlein interfaceIoSession- Returns:
trueif this session isIdleStatus.WRITER_IDLE.- See Also:
-
getIdleCount
- Specified by:
getIdleCountin interfaceIoSession- Parameters:
status- The researched idle status- Returns:
- the number of the fired continuous
sessionIdleevents for the specifiedIdleStatus.If
sessionIdleevent is fired first after some time after I/O,idleCountbecomes1.idleCountresets to0if any I/O occurs again, otherwise it increases to2and so on ifsessionIdleevent is fired again without any I/O between two (or more)sessionIdleevents.
-
getLastIdleTime
- Specified by:
getLastIdleTimein interfaceIoSession- Parameters:
status- The researched idle status- Returns:
- the time in milliseconds when the last
sessionIdleevent is fired for the specifiedIdleStatus.
-
increaseIdleCount
Increase the count of the various Idle counter- Parameters:
status- The current statuscurrentTime- The current time
-
getBothIdleCount
public final int getBothIdleCount()- Specified by:
getBothIdleCountin interfaceIoSession- Returns:
- the number of the fired continuous
sessionIdleevents forIdleStatus.BOTH_IDLE. - See Also:
-
getLastBothIdleTime
public final long getLastBothIdleTime()- Specified by:
getLastBothIdleTimein interfaceIoSession- Returns:
- the time in milliseconds when the last
sessionIdleevent is fired forIdleStatus.BOTH_IDLE. - See Also:
-
getLastReaderIdleTime
public final long getLastReaderIdleTime()- Specified by:
getLastReaderIdleTimein interfaceIoSession- Returns:
- the time in milliseconds when the last
sessionIdleevent is fired forIdleStatus.READER_IDLE. - See Also:
-
getLastWriterIdleTime
public final long getLastWriterIdleTime()- Specified by:
getLastWriterIdleTimein interfaceIoSession- Returns:
- the time in milliseconds when the last
sessionIdleevent is fired forIdleStatus.WRITER_IDLE. - See Also:
-
getReaderIdleCount
public final int getReaderIdleCount()- Specified by:
getReaderIdleCountin interfaceIoSession- Returns:
- the number of the fired continuous
sessionIdleevents forIdleStatus.READER_IDLE. - See Also:
-
getWriterIdleCount
public final int getWriterIdleCount()- Specified by:
getWriterIdleCountin interfaceIoSession- Returns:
- the number of the fired continuous
sessionIdleevents forIdleStatus.WRITER_IDLE. - See Also:
-
getServiceAddress
- Specified by:
getServiceAddressin interfaceIoSession- Returns:
- the socket address of the
IoServicelistens to to manage this session. If this session is managed byIoAcceptor, it returns theSocketAddresswhich is specified as a parameter ofIoAcceptor.bind(). If this session is managed byIoConnector, this method returns the same address with that ofIoSession.getRemoteAddress().
-
hashCode
-
equals
-
toString
-
getIdAsString
Get the Id as a String -
getServiceName
TGet the Service name -
getService
- Specified by:
getServicein interfaceIoSession- Returns:
- the
IoServicewhich provides I/O service to this session.
-
notifyIdleness
Fires aIoEventType.SESSION_IDLEevent to any applicable sessions in the specified collection.- Parameters:
sessions- The sessions that are notifiedcurrentTime- the current time (i.e.System.currentTimeMillis())
-
notifyIdleSession
Fires aIoEventType.SESSION_IDLEevent if applicable for the specifiedsession.- Parameters:
session- The session that is notifiedcurrentTime- the current time (i.e.System.currentTimeMillis())
-
notifyIdleSession0
private static void notifyIdleSession0(IoSession session, long currentTime, long idleTime, IdleStatus status, long lastIoTime) -
notifyWriteTimeout
-