public abstract class AbstractIoService extends java.lang.Object implements IoService
IoService
s.Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractIoService.ServiceOperationFuture |
Modifier | Constructor and Description |
---|---|
protected |
AbstractIoService(IoSessionConfig sessionConfig) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(IoServiceListener listener)
Adds an
IoServiceListener that listens any events related with
this service. |
java.util.Set<WriteFuture> |
broadcast(java.lang.Object message)
Writes the specified
message to all the IoSession s
managed by this service. |
protected void |
decreaseScheduledWriteMessages() |
void |
dispose()
Releases any resources allocated by this service.
|
protected abstract IoFuture |
dispose0()
Implement this method to release any acquired resources.
|
protected void |
finishSessionInitialization(IoSession session,
IoFuture future,
IoSessionInitializer sessionInitializer) |
protected void |
finishSessionInitialization0(IoSession session,
IoFuture future)
Implement this method to perform additional tasks required for session
initialization.
|
long |
getActivationTime()
Returns the time when this service was activated.
|
int |
getBothIdleCount()
Returns the number of the fired continuous serviceIdle events
for
IdleStatus.BOTH_IDLE . |
int |
getBothIdleTime()
Returns idle time for
IdleStatus.BOTH_IDLE in seconds. |
long |
getBothIdleTimeInMillis()
Returns idle time for
IdleStatus.BOTH_IDLE in milliseconds. |
long |
getCumulativeManagedSessionCount()
Returns the cumulative number of sessions which were managed (or are
being managed) by this service, which means 'currently managed session
count + closed session count'.
|
DefaultIoFilterChainBuilder |
getFilterChain()
A shortcut for ( ( DefaultIoFilterChainBuilder )
IoService.getFilterChainBuilder() ). |
IoFilterChainBuilder |
getFilterChainBuilder()
Returns the
IoFilterChainBuilder which will build the
IoFilterChain of all IoSession s which is created
by this service. |
IoHandler |
getHandler()
Returns the handler which will handle all connections managed by this service.
|
int |
getIdleCount(IdleStatus status)
Returns the number of the fired continuous serviceIdle events
for the specified
IdleStatus . |
int |
getIdleTime(IdleStatus status)
Returns idle time for the specified type of idleness in seconds.
|
long |
getIdleTimeInMillis(IdleStatus status)
Returns idle time for the specified type of idleness in milliseconds.
|
int |
getLargestManagedSessionCount()
Returns the maximum number of sessions which were being managed at the
same time.
|
double |
getLargestReadBytesThroughput()
Returns the maximum of the
readBytesThroughput . |
double |
getLargestReadMessagesThroughput()
Returns the maximum of the
readMessagesThroughput . |
double |
getLargestWrittenBytesThroughput()
Returns the maximum of the
writtenBytesThroughput . |
double |
getLargestWrittenMessagesThroughput()
Returns the maximum of the
writtenMessagesThroughput . |
long |
getLastBothIdleTime()
Returns the time in milliseconds when the last serviceIdle event
is fired for
IdleStatus.BOTH_IDLE . |
long |
getLastIdleTime(IdleStatus status)
Returns the time in milliseconds when the last serviceIdle event
is fired for the specified
IdleStatus . |
long |
getLastIoTime()
Returns the time in millis when I/O occurred lastly.
|
long |
getLastReaderIdleTime()
Returns the time in milliseconds when the last serviceIdle event
is fired for
IdleStatus.READER_IDLE . |
long |
getLastReadTime()
Returns the time in millis when read operation occurred lastly.
|
long |
getLastWriterIdleTime()
Returns the time in milliseconds when the last serviceIdle event
is fired for
IdleStatus.WRITER_IDLE . |
long |
getLastWriteTime()
Returns the time in millis when write operation occurred lastly.
|
protected IoServiceListenerSupport |
getListeners() |
int |
getManagedSessionCount()
Returns the number of all sessions which are currently managed by this
service.
|
java.util.Set<IoSession> |
getManagedSessions()
Returns all sessions which are currently managed by this service.
|
long |
getReadBytes()
Returns the number of bytes read by this service
|
double |
getReadBytesThroughput()
Returns the number of read bytes per second.
|
int |
getReaderIdleCount()
Returns the number of the fired continuous serviceIdle events
for
IdleStatus.READER_IDLE . |
int |
getReaderIdleTime()
Returns idle time for
IdleStatus.READER_IDLE in seconds. |
long |
getReaderIdleTimeInMillis()
Returns idle time for
IdleStatus.READER_IDLE in milliseconds. |
long |
getReadMessages()
Returns the number of messages this services has read
|
double |
getReadMessagesThroughput()
Returns the number of read messages per second.
|
long |
getScheduledWriteBytes()
Returns the number of bytes scheduled to be written
|
long |
getScheduledWriteMessages()
Returns the number of messages scheduled to be written
|
IoSessionConfig |
getSessionConfig()
Returns the default configuration of the new
IoSession s
created by this service. |
IoSessionDataStructureFactory |
getSessionDataStructureFactory()
Returns the
IoSessionDataStructureFactory that provides
related data structures for a new session created by this service. |
int |
getThroughputCalculationInterval()
Returns the interval (seconds) between each throughput calculation.
|
long |
getThroughputCalculationIntervalInMillis()
Returns the interval (milliseconds) between each throughput calculation.
|
int |
getWriterIdleCount()
Returns the number of the fired continuous serviceIdle events
for
IdleStatus.WRITER_IDLE . |
int |
getWriterIdleTime()
Returns idle time for
IdleStatus.WRITER_IDLE in seconds. |
long |
getWriterIdleTimeInMillis()
Returns idle time for
IdleStatus.WRITER_IDLE in milliseconds. |
long |
getWrittenBytes()
Returns the number of bytes written out by this service
|
double |
getWrittenBytesThroughput()
Returns the number of written bytes per second.
|
long |
getWrittenMessages()
Returns the number of messages this service has written
|
double |
getWrittenMessagesThroughput()
Returns the number of written messages per second.
|
protected void |
increaseReadBytes(long increment,
long currentTime) |
protected void |
increaseReadMessages(long currentTime) |
protected void |
increaseScheduledWriteBytes(long increment) |
protected void |
increaseScheduledWriteMessages() |
protected void |
increaseWrittenBytes(long increment,
long currentTime) |
protected void |
increaseWrittenMessages(long currentTime) |
boolean |
isActive()
Returns a value of whether or not this service is active
|
boolean |
isBothIdle()
Returns
true if this service is IdleStatus.BOTH_IDLE . |
boolean |
isDisposed()
Returns true if and if only all resources of this processor
have been disposed.
|
boolean |
isDisposing()
Returns true if and if only
IoService.dispose() method has
been called. |
boolean |
isIdle(IdleStatus status)
Returns
true if this service is idle for the specified
IdleStatus . |
boolean |
isReaderIdle()
Returns
true if this service is IdleStatus.READER_IDLE . |
boolean |
isWriterIdle()
Returns
true if this service is IdleStatus.WRITER_IDLE . |
protected void |
notifyIdleness(long currentTime) |
void |
removeListener(IoServiceListener listener)
Removed an existing
IoServiceListener that listens any events
related with this service. |
void |
setBothIdleTime(int idleTime)
Sets idle time for
IdleStatus.WRITER_IDLE in seconds. |
void |
setFilterChainBuilder(IoFilterChainBuilder builder)
Sets the
IoFilterChainBuilder which will build the
IoFilterChain of all IoSession s which is created
by this service. |
void |
setHandler(IoHandler handler)
Sets the handler which will handle all connections managed by this service.
|
void |
setIdleTime(IdleStatus status,
int idleTime)
Sets idle time for the specified type of idleness in seconds.
|
protected void |
setLastReadTime(long lastReadTime) |
protected void |
setLastWriteTime(long lastWriteTime) |
void |
setReaderIdleTime(int idleTime)
Sets idle time for
IdleStatus.READER_IDLE in seconds. |
void |
setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory)
Sets the
IoSessionDataStructureFactory that provides
related data structures for a new session created by this service. |
void |
setThroughputCalculationInterval(int throughputCalculationInterval)
Sets the interval (seconds) between each throughput calculation.
|
void |
setWriterIdleTime(int idleTime)
Sets idle time for
IdleStatus.WRITER_IDLE in seconds. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getTransportMetadata
protected AbstractIoService(IoSessionConfig sessionConfig)
public final IoFilterChainBuilder getFilterChainBuilder()
IoService
IoFilterChainBuilder
which will build the
IoFilterChain
of all IoSession
s which is created
by this service.
The default value is an empty DefaultIoFilterChainBuilder
.getFilterChainBuilder
in interface IoService
public final void setFilterChainBuilder(IoFilterChainBuilder builder)
IoService
IoFilterChainBuilder
which will build the
IoFilterChain
of all IoSession
s which is created
by this service.
If you specify null this property will be set to
an empty DefaultIoFilterChainBuilder
.setFilterChainBuilder
in interface IoService
public final DefaultIoFilterChainBuilder getFilterChain()
IoService
IoService.getFilterChainBuilder()
).
Please note that the returned object is not a real IoFilterChain
but a DefaultIoFilterChainBuilder
. Modifying the returned builder
won't affect the existing IoSession
s at all, because
IoFilterChainBuilder
s affect only newly created IoSession
s.getFilterChain
in interface IoService
public final void addListener(IoServiceListener listener)
IoService
IoServiceListener
that listens any events related with
this service.addListener
in interface IoService
public final void removeListener(IoServiceListener listener)
IoService
IoServiceListener
that listens any events
related with this service.removeListener
in interface IoService
public final boolean isActive()
IoService
public final boolean isDisposing()
IoService
IoService.dispose()
method has
been called. Please note that this method will return true
even after all the related resources are released.isDisposing
in interface IoService
public final boolean isDisposed()
IoService
isDisposed
in interface IoService
public final void dispose()
IoService
protected abstract IoFuture dispose0() throws java.lang.Exception
dispose()
.java.lang.Exception
public final java.util.Set<IoSession> getManagedSessions()
IoService
getManagedSessions
in interface IoService
public final long getCumulativeManagedSessionCount()
IoService
getCumulativeManagedSessionCount
in interface IoService
public final int getLargestManagedSessionCount()
IoService
getLargestManagedSessionCount
in interface IoService
public final int getManagedSessionCount()
IoService
getManagedSessionCount
in interface IoService
public final IoHandler getHandler()
IoService
getHandler
in interface IoService
public final void setHandler(IoHandler handler)
IoService
setHandler
in interface IoService
public IoSessionConfig getSessionConfig()
IoService
IoSession
s
created by this service.getSessionConfig
in interface IoService
public final IoSessionDataStructureFactory getSessionDataStructureFactory()
IoService
IoSessionDataStructureFactory
that provides
related data structures for a new session created by this service.getSessionDataStructureFactory
in interface IoService
public final void setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory)
IoService
IoSessionDataStructureFactory
that provides
related data structures for a new session created by this service.setSessionDataStructureFactory
in interface IoService
public final long getReadBytes()
IoService
getReadBytes
in interface IoService
protected final void increaseReadBytes(long increment, long currentTime)
public final long getReadMessages()
IoService
getReadMessages
in interface IoService
protected final void increaseReadMessages(long currentTime)
public final int getThroughputCalculationInterval()
IoService
getThroughputCalculationInterval
in interface IoService
public final void setThroughputCalculationInterval(int throughputCalculationInterval)
IoService
setThroughputCalculationInterval
in interface IoService
public final long getThroughputCalculationIntervalInMillis()
IoService
getThroughputCalculationIntervalInMillis
in interface IoService
public final double getReadBytesThroughput()
IoService
getReadBytesThroughput
in interface IoService
public final double getWrittenBytesThroughput()
IoService
getWrittenBytesThroughput
in interface IoService
public final double getReadMessagesThroughput()
IoService
getReadMessagesThroughput
in interface IoService
public final double getWrittenMessagesThroughput()
IoService
getWrittenMessagesThroughput
in interface IoService
public final double getLargestReadBytesThroughput()
IoService
readBytesThroughput
.getLargestReadBytesThroughput
in interface IoService
public final double getLargestWrittenBytesThroughput()
IoService
writtenBytesThroughput
.getLargestWrittenBytesThroughput
in interface IoService
public final double getLargestReadMessagesThroughput()
IoService
readMessagesThroughput
.getLargestReadMessagesThroughput
in interface IoService
public final double getLargestWrittenMessagesThroughput()
IoService
writtenMessagesThroughput
.getLargestWrittenMessagesThroughput
in interface IoService
public final long getScheduledWriteBytes()
IoService
getScheduledWriteBytes
in interface IoService
protected final void increaseScheduledWriteBytes(long increment)
public final long getScheduledWriteMessages()
IoService
getScheduledWriteMessages
in interface IoService
protected final void increaseScheduledWriteMessages()
protected final void decreaseScheduledWriteMessages()
public final long getActivationTime()
IoService
getActivationTime
in interface IoService
System.currentTimeMillis()
public final long getLastIoTime()
IoService
getLastIoTime
in interface IoService
public final long getLastReadTime()
IoService
getLastReadTime
in interface IoService
protected final void setLastReadTime(long lastReadTime)
public final long getLastWriteTime()
IoService
getLastWriteTime
in interface IoService
protected final void setLastWriteTime(long lastWriteTime)
public final long getWrittenBytes()
IoService
getWrittenBytes
in interface IoService
protected final void increaseWrittenBytes(long increment, long currentTime)
public final long getWrittenMessages()
IoService
getWrittenMessages
in interface IoService
protected final void increaseWrittenMessages(long currentTime)
public final int getIdleTime(IdleStatus status)
IoService
getIdleTime
in interface IoService
public final long getIdleTimeInMillis(IdleStatus status)
IoService
getIdleTimeInMillis
in interface IoService
public final void setIdleTime(IdleStatus status, int idleTime)
IoService
setIdleTime
in interface IoService
public final boolean isIdle(IdleStatus status)
IoService
true
if this service is idle for the specified
IdleStatus
.public final int getIdleCount(IdleStatus status)
IoService
IdleStatus
.
If serviceIdle event is fired first after some time after I/O,
idleCount becomes 1. idleCount resets to
0 if any I/O occurs again, otherwise it increases to
2 and so on if serviceIdle event is fired again without
any I/O between two (or more) serviceIdle events.getIdleCount
in interface IoService
public final long getLastIdleTime(IdleStatus status)
IoService
IdleStatus
.getLastIdleTime
in interface IoService
protected final void notifyIdleness(long currentTime)
public final int getBothIdleCount()
IoService
IdleStatus.BOTH_IDLE
.getBothIdleCount
in interface IoService
IoService.getIdleCount(IdleStatus)
public final long getLastBothIdleTime()
IoService
IdleStatus.BOTH_IDLE
.getLastBothIdleTime
in interface IoService
IoService.getLastIdleTime(IdleStatus)
public final long getLastReaderIdleTime()
IoService
IdleStatus.READER_IDLE
.getLastReaderIdleTime
in interface IoService
IoService.getLastIdleTime(IdleStatus)
public final long getLastWriterIdleTime()
IoService
IdleStatus.WRITER_IDLE
.getLastWriterIdleTime
in interface IoService
IoService.getLastIdleTime(IdleStatus)
public final int getReaderIdleCount()
IoService
IdleStatus.READER_IDLE
.getReaderIdleCount
in interface IoService
IoService.getIdleCount(IdleStatus)
public final int getWriterIdleCount()
IoService
IdleStatus.WRITER_IDLE
.getWriterIdleCount
in interface IoService
IoService.getIdleCount(IdleStatus)
public final int getBothIdleTime()
IoService
IdleStatus.BOTH_IDLE
in seconds.getBothIdleTime
in interface IoService
public final long getBothIdleTimeInMillis()
IoService
IdleStatus.BOTH_IDLE
in milliseconds.getBothIdleTimeInMillis
in interface IoService
public final int getReaderIdleTime()
IoService
IdleStatus.READER_IDLE
in seconds.getReaderIdleTime
in interface IoService
public final long getReaderIdleTimeInMillis()
IoService
IdleStatus.READER_IDLE
in milliseconds.getReaderIdleTimeInMillis
in interface IoService
public final int getWriterIdleTime()
IoService
IdleStatus.WRITER_IDLE
in seconds.getWriterIdleTime
in interface IoService
public final long getWriterIdleTimeInMillis()
IoService
IdleStatus.WRITER_IDLE
in milliseconds.getWriterIdleTimeInMillis
in interface IoService
public final boolean isBothIdle()
IoService
true
if this service is IdleStatus.BOTH_IDLE
.isBothIdle
in interface IoService
IoService.isIdle(IdleStatus)
public final boolean isReaderIdle()
IoService
true
if this service is IdleStatus.READER_IDLE
.isReaderIdle
in interface IoService
IoService.isIdle(IdleStatus)
public final boolean isWriterIdle()
IoService
true
if this service is IdleStatus.WRITER_IDLE
.isWriterIdle
in interface IoService
IoService.isIdle(IdleStatus)
public final void setBothIdleTime(int idleTime)
IoService
IdleStatus.WRITER_IDLE
in seconds.setBothIdleTime
in interface IoService
public final void setReaderIdleTime(int idleTime)
IoService
IdleStatus.READER_IDLE
in seconds.setReaderIdleTime
in interface IoService
public final void setWriterIdleTime(int idleTime)
IoService
IdleStatus.WRITER_IDLE
in seconds.setWriterIdleTime
in interface IoService
public final java.util.Set<WriteFuture> broadcast(java.lang.Object message)
IoService
message
to all the IoSession
s
managed by this service. This method is a convenience shortcut for
IoUtil.broadcast(Object, Collection)
.protected final IoServiceListenerSupport getListeners()
protected final void finishSessionInitialization(IoSession session, IoFuture future, IoSessionInitializer sessionInitializer)
protected void finishSessionInitialization0(IoSession session, IoFuture future)
finishSessionInitialization(IoSession, IoFuture, IoSessionInitializer)
will call
this method instead.Copyright © 2004-2019 Apache MINA Project. All Rights Reserved.