|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mina.core.service.AbstractIoService
public abstract class AbstractIoService
Base implementation of IoService
s.
Nested Class Summary | |
---|---|
protected static class |
AbstractIoService.ServiceOperationFuture
|
Field Summary | |
---|---|
protected Object |
disposalLock
A lock object which must be acquired when related resources are destroyed. |
Constructor Summary | |
---|---|
protected |
AbstractIoService(IoSessionConfig sessionConfig,
Executor executor)
Constructor for AbstractIoService . |
Method Summary | |
---|---|
void |
addListener(IoServiceListener listener)
Adds an IoServiceListener that listens any events related with
this service. |
Set<WriteFuture> |
broadcast(Object message)
Writes the specified message to all the IoSession s
managed by this service. |
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 |
executeWorker(Runnable worker)
|
protected void |
executeWorker(Runnable worker,
String suffix)
|
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 . |
protected IdleStatusChecker |
getIdleStatusChecker()
|
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. |
IoServiceListenerSupport |
getListeners()
|
int |
getManagedSessionCount()
Returns the number of all sessions which are currently managed by this service. |
Map<Long,IoSession> |
getManagedSessions()
Returns the map of 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. |
int |
getScheduledWriteBytes()
Returns the number of bytes scheduled to be written |
int |
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. |
void |
increaseReadBytes(long increment,
long currentTime)
|
void |
increaseReadMessages(long currentTime)
|
void |
increaseScheduledWriteBytes(int increment)
|
void |
increaseScheduledWriteMessages()
|
void |
increaseWrittenBytes(long increment,
long currentTime)
|
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 . |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.mina.core.service.IoService |
---|
getTransportMetadata |
Field Detail |
---|
protected final Object disposalLock
Constructor Detail |
---|
protected AbstractIoService(IoSessionConfig sessionConfig, Executor executor)
AbstractIoService
. You need to provide a default
session configuration and an Executor
for handling I/O events. If
null Executor
is provided, a default one will be created using
Executors.newCachedThreadPool()
.
sessionConfig
- the default configuration for the managed IoSession
executor
- the Executor
used for handling execution of I/O
events. Can be null
.Method Detail |
---|
public final IoFilterChainBuilder getFilterChainBuilder()
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)
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.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)
IoServiceListener
that listens any events related with
this service.
addListener
in interface IoService
public final void removeListener(IoServiceListener listener)
IoServiceListener
that listens any events
related with this service.
removeListener
in interface IoService
public final boolean isActive()
isActive
in interface IoService
public final boolean isDisposing()
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()
isDisposed
in interface IoService
public final void dispose()
dispose
in interface IoService
protected abstract IoFuture dispose0() throws Exception
dispose()
.
Exception
public final Map<Long,IoSession> getManagedSessions()
ID
of the
session.
getManagedSessions
in interface IoService
public final long getCumulativeManagedSessionCount()
getCumulativeManagedSessionCount
in interface IoService
public final int getLargestManagedSessionCount()
getLargestManagedSessionCount
in interface IoService
public final int getManagedSessionCount()
getManagedSessionCount
in interface IoService
public final IoHandler getHandler()
getHandler
in interface IoService
public final void setHandler(IoHandler handler)
setHandler
in interface IoService
public IoSessionConfig getSessionConfig()
IoSession
s
created by this service.
getSessionConfig
in interface IoService
public final IoSessionDataStructureFactory getSessionDataStructureFactory()
IoSessionDataStructureFactory
that provides
related data structures for a new session created by this service.
getSessionDataStructureFactory
in interface IoService
public final void setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory)
IoSessionDataStructureFactory
that provides
related data structures for a new session created by this service.
setSessionDataStructureFactory
in interface IoService
public final long getReadBytes()
getReadBytes
in interface IoService
public final void increaseReadBytes(long increment, long currentTime)
public final long getReadMessages()
getReadMessages
in interface IoService
public final void increaseReadMessages(long currentTime)
public final int getThroughputCalculationInterval()
getThroughputCalculationInterval
in interface IoService
public final void setThroughputCalculationInterval(int throughputCalculationInterval)
setThroughputCalculationInterval
in interface IoService
public final long getThroughputCalculationIntervalInMillis()
getThroughputCalculationIntervalInMillis
in interface IoService
public final double getReadBytesThroughput()
getReadBytesThroughput
in interface IoService
public final double getWrittenBytesThroughput()
getWrittenBytesThroughput
in interface IoService
public final double getReadMessagesThroughput()
getReadMessagesThroughput
in interface IoService
public final double getWrittenMessagesThroughput()
getWrittenMessagesThroughput
in interface IoService
public final double getLargestReadBytesThroughput()
readBytesThroughput
.
getLargestReadBytesThroughput
in interface IoService
public final double getLargestWrittenBytesThroughput()
writtenBytesThroughput
.
getLargestWrittenBytesThroughput
in interface IoService
public final double getLargestReadMessagesThroughput()
readMessagesThroughput
.
getLargestReadMessagesThroughput
in interface IoService
public final double getLargestWrittenMessagesThroughput()
writtenMessagesThroughput
.
getLargestWrittenMessagesThroughput
in interface IoService
public final int getScheduledWriteBytes()
getScheduledWriteBytes
in interface IoService
public final void increaseScheduledWriteBytes(int increment)
public final int getScheduledWriteMessages()
getScheduledWriteMessages
in interface IoService
public final void increaseScheduledWriteMessages()
public final void decreaseScheduledWriteMessages()
public final long getActivationTime()
getActivationTime
in interface IoService
System.currentTimeMillis()
public final long getLastIoTime()
getLastIoTime
in interface IoService
public final long getLastReadTime()
getLastReadTime
in interface IoService
protected final void setLastReadTime(long lastReadTime)
public final long getLastWriteTime()
getLastWriteTime
in interface IoService
protected final void setLastWriteTime(long lastWriteTime)
public final long getWrittenBytes()
getWrittenBytes
in interface IoService
public final void increaseWrittenBytes(long increment, long currentTime)
public final long getWrittenMessages()
getWrittenMessages
in interface IoService
public final void increaseWrittenMessages(long currentTime)
public final int getIdleTime(IdleStatus status)
getIdleTime
in interface IoService
public final long getIdleTimeInMillis(IdleStatus status)
getIdleTimeInMillis
in interface IoService
public final void setIdleTime(IdleStatus status, int idleTime)
setIdleTime
in interface IoService
public final boolean isIdle(IdleStatus status)
true
if this service is idle for the specified
IdleStatus
.
isIdle
in interface IoService
public final int getIdleCount(IdleStatus status)
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)
IdleStatus
.
getLastIdleTime
in interface IoService
public final void notifyIdleness(long currentTime)
public final int getBothIdleCount()
IdleStatus.BOTH_IDLE
.
getBothIdleCount
in interface IoService
IoService.getIdleCount(IdleStatus)
public final long getLastBothIdleTime()
IdleStatus.BOTH_IDLE
.
getLastBothIdleTime
in interface IoService
IoService.getLastIdleTime(IdleStatus)
public final long getLastReaderIdleTime()
IdleStatus.READER_IDLE
.
getLastReaderIdleTime
in interface IoService
IoService.getLastIdleTime(IdleStatus)
public final long getLastWriterIdleTime()
IdleStatus.WRITER_IDLE
.
getLastWriterIdleTime
in interface IoService
IoService.getLastIdleTime(IdleStatus)
public final int getReaderIdleCount()
IdleStatus.READER_IDLE
.
getReaderIdleCount
in interface IoService
IoService.getIdleCount(IdleStatus)
public final int getWriterIdleCount()
IdleStatus.WRITER_IDLE
.
getWriterIdleCount
in interface IoService
IoService.getIdleCount(IdleStatus)
public final int getBothIdleTime()
IdleStatus.BOTH_IDLE
in seconds.
getBothIdleTime
in interface IoService
public final long getBothIdleTimeInMillis()
IdleStatus.BOTH_IDLE
in milliseconds.
getBothIdleTimeInMillis
in interface IoService
public final int getReaderIdleTime()
IdleStatus.READER_IDLE
in seconds.
getReaderIdleTime
in interface IoService
public final long getReaderIdleTimeInMillis()
IdleStatus.READER_IDLE
in milliseconds.
getReaderIdleTimeInMillis
in interface IoService
public final int getWriterIdleTime()
IdleStatus.WRITER_IDLE
in seconds.
getWriterIdleTime
in interface IoService
public final long getWriterIdleTimeInMillis()
IdleStatus.WRITER_IDLE
in milliseconds.
getWriterIdleTimeInMillis
in interface IoService
public final boolean isBothIdle()
true
if this service is IdleStatus.BOTH_IDLE
.
isBothIdle
in interface IoService
IoService.isIdle(IdleStatus)
public final boolean isReaderIdle()
true
if this service is IdleStatus.READER_IDLE
.
isReaderIdle
in interface IoService
IoService.isIdle(IdleStatus)
public final boolean isWriterIdle()
true
if this service is IdleStatus.WRITER_IDLE
.
isWriterIdle
in interface IoService
IoService.isIdle(IdleStatus)
public final void setBothIdleTime(int idleTime)
IdleStatus.WRITER_IDLE
in seconds.
setBothIdleTime
in interface IoService
public final void setReaderIdleTime(int idleTime)
IdleStatus.READER_IDLE
in seconds.
setReaderIdleTime
in interface IoService
public final void setWriterIdleTime(int idleTime)
IdleStatus.WRITER_IDLE
in seconds.
setWriterIdleTime
in interface IoService
public final Set<WriteFuture> broadcast(Object message)
message
to all the IoSession
s
managed by this service. This method is a convenience shortcut for
IoUtil.broadcast(Object, Collection)
.
broadcast
in interface IoService
public final IoServiceListenerSupport getListeners()
protected final IdleStatusChecker getIdleStatusChecker()
protected final void executeWorker(Runnable worker)
protected final void executeWorker(Runnable worker, String suffix)
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |