org.apache.mina.common
Interface IoService

All Known Subinterfaces:
DatagramAcceptor, DatagramConnector, DatagramService, IoAcceptor, IoConnector, SocketAcceptor, SocketConnector, SocketService
All Known Implementing Classes:
AbstractIoAcceptor, AbstractIoConnector, AbstractIoService, AbstractPollingConnectionlessIoAcceptor, AbstractPollingIoAcceptor, AbstractPollingIoConnector, AprSocketAcceptor, AprSocketConnector, NioDatagramAcceptor, NioDatagramConnector, NioSocketAcceptor, NioSocketConnector, VmPipeAcceptor, VmPipeConnector

public interface IoService

Base interface for all IoAcceptors and IoConnectors that provide I/O service and manage IoSessions.

Version:
$Rev: 606098 $, $Date: 2007-12-21 06:11:58 +0100 (Fri, 21 Dec 2007) $
Author:
The Apache MINA Project (dev@mina.apache.org)

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 IoSessions managed by this service.
 void dispose()
          Releases any resources allocated by this service.
 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 ) getFilterChainBuilder() ).
 IoFilterChainBuilder getFilterChainBuilder()
          Returns the IoFilterChainBuilder which will build the IoFilterChain of all IoSessions 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.
 int getManagedSessionCount()
          Returns the number of all sessions which are currently managed by this service.
 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 IoSessions 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.
 TransportMetadata getTransportMetadata()
          Returns the TransportMetadata that this service runs on.
 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.
 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 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 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 IoSessions 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.
 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.
 

Method Detail

getTransportMetadata

TransportMetadata getTransportMetadata()
Returns the TransportMetadata that this service runs on.


addListener

void addListener(IoServiceListener listener)
Adds an IoServiceListener that listens any events related with this service.


removeListener

void removeListener(IoServiceListener listener)
Removed an existing IoServiceListener that listens any events related with this service.


isDisposing

boolean isDisposing()
Returns true if and if only dispose() method has been called. Please note that this method will return true even after all the related resources are released.


isDisposed

boolean isDisposed()
Returns true if and if only all resources of this processor have been disposed.


dispose

void dispose()
Releases any resources allocated by this service. Please note that this method might block as long as there are any sessions managed by this service.


getHandler

IoHandler getHandler()
Returns the handler which will handle all connections managed by this service.


setHandler

void setHandler(IoHandler handler)
Sets the handler which will handle all connections managed by this service.


getManagedSessions

Set<IoSession> getManagedSessions()
Returns all sessions which are currently managed by this service.

Returns:
the sessions. An empty collection if there's no session.

getManagedSessionCount

int getManagedSessionCount()
Returns the number of all sessions which are currently managed by this service.


getLargestManagedSessionCount

int getLargestManagedSessionCount()
Returns the maximum number of sessions which were being managed at the same time.


getCumulativeManagedSessionCount

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'.


getSessionConfig

IoSessionConfig getSessionConfig()
Returns the default configuration of the new IoSessions created by this service.


getFilterChainBuilder

IoFilterChainBuilder getFilterChainBuilder()
Returns the IoFilterChainBuilder which will build the IoFilterChain of all IoSessions which is created by this service. The default value is an empty DefaultIoFilterChainBuilder.


setFilterChainBuilder

void setFilterChainBuilder(IoFilterChainBuilder builder)
Sets the IoFilterChainBuilder which will build the IoFilterChain of all IoSessions which is created by this service. If you specify null this property will be set to an empty DefaultIoFilterChainBuilder.


getFilterChain

DefaultIoFilterChainBuilder getFilterChain()
A shortcut for ( ( DefaultIoFilterChainBuilder ) getFilterChainBuilder() ). Please note that the returned object is not a real IoFilterChain but a DefaultIoFilterChainBuilder. Modifying the returned builder won't affect the existing IoSessions at all, because IoFilterChainBuilders affect only newly created IoSessions.

Throws:
IllegalStateException - if the current IoFilterChainBuilder is not a DefaultIoFilterChainBuilder

isActive

boolean isActive()
Returns a value of whether or not this service is active

Returns:
whether of not the service is active.

getActivationTime

long getActivationTime()
Returns the time when this service was activated. It returns the last time when this service was activated if the service is not active now.

Returns:
The time by using System.currentTimeMillis()

getLastIoTime

long getLastIoTime()
Returns the time in millis when I/O occurred lastly.


getLastReadTime

long getLastReadTime()
Returns the time in millis when read operation occurred lastly.


getLastWriteTime

long getLastWriteTime()
Returns the time in millis when write operation occurred lastly.


isIdle

boolean isIdle(IdleStatus status)
Returns true if this service is idle for the specified IdleStatus.


isReaderIdle

boolean isReaderIdle()
Returns true if this service is IdleStatus.READER_IDLE.

See Also:
isIdle(IdleStatus)

isWriterIdle

boolean isWriterIdle()
Returns true if this service is IdleStatus.WRITER_IDLE.

See Also:
isIdle(IdleStatus)

isBothIdle

boolean isBothIdle()
Returns true if this service is IdleStatus.BOTH_IDLE.

See Also:
isIdle(IdleStatus)

getIdleCount

int getIdleCount(IdleStatus status)
Returns the number of the fired continuous serviceIdle events for the specified 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.


getReaderIdleCount

int getReaderIdleCount()
Returns the number of the fired continuous serviceIdle events for IdleStatus.READER_IDLE.

See Also:
getIdleCount(IdleStatus)

getWriterIdleCount

int getWriterIdleCount()
Returns the number of the fired continuous serviceIdle events for IdleStatus.WRITER_IDLE.

See Also:
getIdleCount(IdleStatus)

getBothIdleCount

int getBothIdleCount()
Returns the number of the fired continuous serviceIdle events for IdleStatus.BOTH_IDLE.

See Also:
getIdleCount(IdleStatus)

getLastIdleTime

long getLastIdleTime(IdleStatus status)
Returns the time in milliseconds when the last serviceIdle event is fired for the specified IdleStatus.


getLastReaderIdleTime

long getLastReaderIdleTime()
Returns the time in milliseconds when the last serviceIdle event is fired for IdleStatus.READER_IDLE.

See Also:
getLastIdleTime(IdleStatus)

getLastWriterIdleTime

long getLastWriterIdleTime()
Returns the time in milliseconds when the last serviceIdle event is fired for IdleStatus.WRITER_IDLE.

See Also:
getLastIdleTime(IdleStatus)

getLastBothIdleTime

long getLastBothIdleTime()
Returns the time in milliseconds when the last serviceIdle event is fired for IdleStatus.BOTH_IDLE.

See Also:
getLastIdleTime(IdleStatus)

getIdleTime

int getIdleTime(IdleStatus status)
Returns idle time for the specified type of idleness in seconds.


getIdleTimeInMillis

long getIdleTimeInMillis(IdleStatus status)
Returns idle time for the specified type of idleness in milliseconds.


setIdleTime

void setIdleTime(IdleStatus status,
                 int idleTime)
Sets idle time for the specified type of idleness in seconds.


getReaderIdleTime

int getReaderIdleTime()
Returns idle time for IdleStatus.READER_IDLE in seconds.


getReaderIdleTimeInMillis

long getReaderIdleTimeInMillis()
Returns idle time for IdleStatus.READER_IDLE in milliseconds.


setReaderIdleTime

void setReaderIdleTime(int idleTime)
Sets idle time for IdleStatus.READER_IDLE in seconds.


getWriterIdleTime

int getWriterIdleTime()
Returns idle time for IdleStatus.WRITER_IDLE in seconds.


getWriterIdleTimeInMillis

long getWriterIdleTimeInMillis()
Returns idle time for IdleStatus.WRITER_IDLE in milliseconds.


setWriterIdleTime

void setWriterIdleTime(int idleTime)
Sets idle time for IdleStatus.WRITER_IDLE in seconds.


getBothIdleTime

int getBothIdleTime()
Returns idle time for IdleStatus.BOTH_IDLE in seconds.


getBothIdleTimeInMillis

long getBothIdleTimeInMillis()
Returns idle time for IdleStatus.BOTH_IDLE in milliseconds.


setBothIdleTime

void setBothIdleTime(int idleTime)
Sets idle time for IdleStatus.WRITER_IDLE in seconds.


getReadBytes

long getReadBytes()
Returns the number of bytes read by this service

Returns:
The number of bytes this service has read

getWrittenBytes

long getWrittenBytes()
Returns the number of bytes written out by this service

Returns:
The number of bytes this service has written

getReadMessages

long getReadMessages()
Returns the number of messages this services has read

Returns:
The number of messages this services has read

getWrittenMessages

long getWrittenMessages()
Returns the number of messages this service has written

Returns:
The number of messages this service has written

getReadBytesThroughput

double getReadBytesThroughput()
Returns the number of read bytes per second.


getWrittenBytesThroughput

double getWrittenBytesThroughput()
Returns the number of written bytes per second.


getReadMessagesThroughput

double getReadMessagesThroughput()
Returns the number of read messages per second.


getWrittenMessagesThroughput

double getWrittenMessagesThroughput()
Returns the number of written messages per second.


getLargestReadBytesThroughput

double getLargestReadBytesThroughput()
Returns the maximum of the readBytesThroughput.


getLargestWrittenBytesThroughput

double getLargestWrittenBytesThroughput()
Returns the maximum of the writtenBytesThroughput.


getLargestReadMessagesThroughput

double getLargestReadMessagesThroughput()
Returns the maximum of the readMessagesThroughput.


getLargestWrittenMessagesThroughput

double getLargestWrittenMessagesThroughput()
Returns the maximum of the writtenMessagesThroughput.


getThroughputCalculationInterval

int getThroughputCalculationInterval()
Returns the interval (seconds) between each throughput calculation. The default value is 3 seconds.


getThroughputCalculationIntervalInMillis

long getThroughputCalculationIntervalInMillis()
Returns the interval (milliseconds) between each throughput calculation. The default value is 3 seconds.


setThroughputCalculationInterval

void setThroughputCalculationInterval(int throughputCalculationInterval)
Sets the interval (seconds) between each throughput calculation. The default value is 3 seconds.


getScheduledWriteBytes

long getScheduledWriteBytes()
Returns the number of bytes scheduled to be written

Returns:
The number of bytes scheduled to be written

getScheduledWriteMessages

long getScheduledWriteMessages()
Returns the number of messages scheduled to be written

Returns:
The number of messages scheduled to be written

broadcast

Set<WriteFuture> broadcast(Object message)
Writes the specified message to all the IoSessions managed by this service. This method is a convenience shortcut for IoUtil.broadcast(Object, Collection).


getSessionDataStructureFactory

IoSessionDataStructureFactory getSessionDataStructureFactory()
Returns the IoSessionDataStructureFactory that provides related data structures for a new session created by this service.


setSessionDataStructureFactory

void setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory)
Sets the IoSessionDataStructureFactory that provides related data structures for a new session created by this service.



Copyright © 2004-2009 Apache MINA Project. All Rights Reserved.