Class IoServiceStatistics

java.lang.Object
org.apache.mina.core.service.IoServiceStatistics

public class IoServiceStatistics extends Object
Provides usage statistics for an AbstractIoService instance.
Since:
2.0.0-M3
  • Field Details

    • 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 Lock throughputCalculationLock
    • config

      private final IoServiceStatistics.Config config
  • Constructor Details

    • IoServiceStatistics

      public IoServiceStatistics(IoService service)
      Creates a new IoServiceStatistics instance
      Parameters:
      service - The IoService for which we want statistics
  • Method Details

    • 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 3 seconds.
    • getThroughputCalculationIntervalInMillis

      public final long getThroughputCalculationIntervalInMillis()
      Returns:
      the interval (milliseconds) between each throughput calculation. The default value is 3 seconds.
    • setThroughputCalculationInterval

      public final void setThroughputCalculationInterval(int throughputCalculationInterval)
      Sets the interval (seconds) between each throughput calculation. The default value is 3 seconds.
      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 by nbBytesRead and sets the last read time to currentTime.
      Parameters:
      nbBytesRead - The number of bytes read
      currentTime - 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 to currentTime.
      Parameters:
      currentTime - The time the message has been read
    • increaseWrittenBytes

      public final void increaseWrittenBytes(int nbBytesWritten, long currentTime)
      Increases the count of written bytes by nbBytesWritten and sets the last write time to currentTime.
      Parameters:
      nbBytesWritten - The number of bytes written
      currentTime - 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 to currentTime.
      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 by increment the 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