Package org.apache.mina.core.service
Class IoServiceStatistics
- java.lang.Object
-
- org.apache.mina.core.service.IoServiceStatistics
-
public class IoServiceStatistics extends java.lang.ObjectProvides usage statistics for anAbstractIoServiceinstance.- Since:
- 2.0.0-M3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIoServiceStatistics.ConfigThis is a configuration for IoServiceStatistics.
-
Field Summary
Fields Modifier and Type Field Description private IoServiceStatistics.Configconfigprivate doublelargestReadBytesThroughputThe biggest number of bytes read per secondprivate doublelargestReadMessagesThroughputThe biggest number of messages read per secondprivate doublelargestWrittenBytesThroughputThe biggest number of bytes written per secondprivate doublelargestWrittenMessagesThroughputThe biggest number of messages written per secondprivate longlastReadBytesprivate longlastReadMessagesprivate longlastReadTimeThe time the last read operation occurredprivate longlastThroughputCalculationTimeprivate longlastWriteTimeThe time the last write operation occurredprivate longlastWrittenBytesprivate longlastWrittenMessagesprivate longreadBytesThe number of read bytes since the service has been startedprivate doublereadBytesThroughputThe number of bytes read per secondprivate longreadMessagesThe number of read messages since the service has been startedprivate doublereadMessagesThroughputThe number of messages read per secondprivate intscheduledWriteBytesprivate intscheduledWriteMessagesprivate IoServiceserviceprivate java.util.concurrent.locks.LockthroughputCalculationLockprivate longwrittenBytesThe number of written bytes since the service has been startedprivate doublewrittenBytesThroughputThe number of bytes written per secondprivate longwrittenMessagesThe number of written messages since the service has been startedprivate doublewrittenMessagesThroughputThe number of messages written per second
-
Constructor Summary
Constructors Constructor Description IoServiceStatistics(IoService service)Creates a new IoServiceStatistics instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddecreaseScheduledWriteMessages()Decrements the count of messages scheduled for write.IoServiceStatistics.ConfiggetConfig()longgetCumulativeManagedSessionCount()intgetLargestManagedSessionCount()doublegetLargestReadBytesThroughput()doublegetLargestReadMessagesThroughput()doublegetLargestWrittenBytesThroughput()doublegetLargestWrittenMessagesThroughput()longgetLastIoTime()longgetLastReadTime()longgetLastWriteTime()longgetReadBytes()doublegetReadBytesThroughput()longgetReadMessages()doublegetReadMessagesThroughput()intgetScheduledWriteBytes()intgetScheduledWriteMessages()intgetThroughputCalculationInterval()longgetThroughputCalculationIntervalInMillis()longgetWrittenBytes()doublegetWrittenBytesThroughput()longgetWrittenMessages()doublegetWrittenMessagesThroughput()voidincreaseReadBytes(long nbBytesRead, long currentTime)Increases the count of read bytes bynbBytesReadand sets the last read time tocurrentTime.voidincreaseReadMessages(long currentTime)Increases the count of read messages by 1 and sets the last read time tocurrentTime.voidincreaseScheduledWriteBytes(int increment)Increments byincrementthe count of bytes scheduled for write.voidincreaseScheduledWriteMessages()Increments the count of messages scheduled for write.voidincreaseWrittenBytes(int nbBytesWritten, long currentTime)Increases the count of written bytes bynbBytesWrittenand sets the last write time tocurrentTime.voidincreaseWrittenMessages(long currentTime)Increases the count of written messages by 1 and sets the last write time tocurrentTime.private voidresetThroughput()Resets the throughput counters of the service if no session is currently managed.protected voidsetLastReadTime(long lastReadTime)Sets last time at which a read occurred on the service.protected voidsetLastThroughputCalculationTime(long lastThroughputCalculationTime)Sets the time at which throughput counters where updated.protected voidsetLastWriteTime(long lastWriteTime)Sets last time at which a write occurred on the service.voidsetThroughputCalculationInterval(int throughputCalculationInterval)Sets the interval (seconds) between each throughput calculation.voidupdateThroughput(long currentTime)Updates the throughput counters.
-
-
-
Field Detail
-
service
private final IoService service
-
readBytesThroughput
private double readBytesThroughput
The number of bytes read per second
-
writtenBytesThroughput
private double writtenBytesThroughput
The number of bytes written per second
-
readMessagesThroughput
private double readMessagesThroughput
The number of messages read per second
-
writtenMessagesThroughput
private double writtenMessagesThroughput
The number of messages written per second
-
largestReadBytesThroughput
private double largestReadBytesThroughput
The biggest number of bytes read per second
-
largestWrittenBytesThroughput
private double largestWrittenBytesThroughput
The biggest number of bytes written per second
-
largestReadMessagesThroughput
private double largestReadMessagesThroughput
The biggest number of messages read per second
-
largestWrittenMessagesThroughput
private double largestWrittenMessagesThroughput
The biggest number of messages written per second
-
readBytes
private long readBytes
The number of read bytes since the service has been started
-
writtenBytes
private long writtenBytes
The number of written bytes since the service has been started
-
readMessages
private long readMessages
The number of read messages since the service has been started
-
writtenMessages
private long writtenMessages
The number of written messages since the service has been started
-
lastReadTime
private long lastReadTime
The time the last read operation occurred
-
lastWriteTime
private long lastWriteTime
The time the last write operation occurred
-
lastReadBytes
private long lastReadBytes
-
lastWrittenBytes
private long lastWrittenBytes
-
lastReadMessages
private long lastReadMessages
-
lastWrittenMessages
private long lastWrittenMessages
-
lastThroughputCalculationTime
private long lastThroughputCalculationTime
-
scheduledWriteBytes
private int scheduledWriteBytes
-
scheduledWriteMessages
private int scheduledWriteMessages
-
throughputCalculationLock
private final java.util.concurrent.locks.Lock throughputCalculationLock
-
config
private final IoServiceStatistics.Config config
-
-
Method Detail
-
getLargestManagedSessionCount
public final int getLargestManagedSessionCount()
- Returns:
- The maximum number of sessions which were being managed at the same time.
-
getCumulativeManagedSessionCount
public final 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'.
-
getLastIoTime
public final long getLastIoTime()
- Returns:
- the time in millis when the last I/O operation (read or write) occurred.
-
getLastReadTime
public final long getLastReadTime()
- Returns:
- The time in millis when the last read operation occurred.
-
getLastWriteTime
public final long getLastWriteTime()
- Returns:
- The time in millis when the last write operation occurred.
-
getReadBytes
public final long getReadBytes()
- Returns:
- The number of bytes this service has read so far
-
getWrittenBytes
public final long getWrittenBytes()
- Returns:
- The number of bytes this service has written so far
-
getReadMessages
public final long getReadMessages()
- Returns:
- The number of messages this services has read so far
-
getWrittenMessages
public final long getWrittenMessages()
- Returns:
- The number of messages this service has written so far
-
getReadBytesThroughput
public final double getReadBytesThroughput()
- Returns:
- The number of read bytes per second.
-
getWrittenBytesThroughput
public final double getWrittenBytesThroughput()
- Returns:
- The number of written bytes per second.
-
getReadMessagesThroughput
public final double getReadMessagesThroughput()
- Returns:
- The number of read messages per second.
-
getWrittenMessagesThroughput
public final double getWrittenMessagesThroughput()
- Returns:
- The number of written messages per second.
-
getLargestReadBytesThroughput
public final double getLargestReadBytesThroughput()
- Returns:
- The maximum number of bytes read per second since the service has been started.
-
getLargestWrittenBytesThroughput
public final double getLargestWrittenBytesThroughput()
- Returns:
- The maximum number of bytes written per second since the service has been started.
-
getLargestReadMessagesThroughput
public final double getLargestReadMessagesThroughput()
- Returns:
- The maximum number of messages read per second since the service has been started.
-
getLargestWrittenMessagesThroughput
public final double getLargestWrittenMessagesThroughput()
- Returns:
- The maximum number of messages written per second since the service has been started.
-
getThroughputCalculationInterval
public final int getThroughputCalculationInterval()
- Returns:
- the interval (seconds) between each throughput calculation. The
default value is
3seconds.
-
getThroughputCalculationIntervalInMillis
public final long getThroughputCalculationIntervalInMillis()
- Returns:
- the interval (milliseconds) between each throughput calculation.
The default value is
3seconds.
-
setThroughputCalculationInterval
public final void setThroughputCalculationInterval(int throughputCalculationInterval)
Sets the interval (seconds) between each throughput calculation. The default value is3seconds.- Parameters:
throughputCalculationInterval- The interval between two calculation
-
setLastReadTime
protected final void setLastReadTime(long lastReadTime)
Sets last time at which a read occurred on the service.- Parameters:
lastReadTime- The last time a read has occurred
-
setLastWriteTime
protected final void setLastWriteTime(long lastWriteTime)
Sets last time at which a write occurred on the service.- Parameters:
lastWriteTime- The last time a write has occurred
-
resetThroughput
private void resetThroughput()
Resets the throughput counters of the service if no session is currently managed.
-
updateThroughput
public void updateThroughput(long currentTime)
Updates the throughput counters.- Parameters:
currentTime- The current time
-
increaseReadBytes
public final void increaseReadBytes(long nbBytesRead, long currentTime)Increases the count of read bytes bynbBytesReadand sets the last read time tocurrentTime.- Parameters:
nbBytesRead- The number of bytes readcurrentTime- The date those bytes were read
-
increaseReadMessages
public final void increaseReadMessages(long currentTime)
Increases the count of read messages by 1 and sets the last read time tocurrentTime.- Parameters:
currentTime- The time the message has been read
-
increaseWrittenBytes
public final void increaseWrittenBytes(int nbBytesWritten, long currentTime)Increases the count of written bytes bynbBytesWrittenand sets the last write time tocurrentTime.- Parameters:
nbBytesWritten- The number of bytes writtencurrentTime- The date those bytes were written
-
increaseWrittenMessages
public final void increaseWrittenMessages(long currentTime)
Increases the count of written messages by 1 and sets the last write time tocurrentTime.- Parameters:
currentTime- The date the message were written
-
getScheduledWriteBytes
public final int getScheduledWriteBytes()
- Returns:
- The count of bytes scheduled for write.
-
increaseScheduledWriteBytes
public final void increaseScheduledWriteBytes(int increment)
Increments byincrementthe count of bytes scheduled for write.- Parameters:
increment- The number of added bytes fro write
-
getScheduledWriteMessages
public final int getScheduledWriteMessages()
- Returns:
- the count of messages scheduled for write.
-
increaseScheduledWriteMessages
public final void increaseScheduledWriteMessages()
Increments the count of messages scheduled for write.
-
decreaseScheduledWriteMessages
public final void decreaseScheduledWriteMessages()
Decrements the count of messages scheduled for write.
-
setLastThroughputCalculationTime
protected void setLastThroughputCalculationTime(long lastThroughputCalculationTime)
Sets the time at which throughput counters where updated.- Parameters:
lastThroughputCalculationTime- The time at which throughput counters where updated.
-
getConfig
public final IoServiceStatistics.Config getConfig()
- Returns:
- The configuration of IoServiceStatistics
-
-