Class ServerTrafficCounter


  • public class ServerTrafficCounter
    extends Object
    A ServerTrafficCounter counts the number of bytes read and written by the server. This includes client-server, server-server, external components and connection managers traffic. Note that traffic is monitored only for entities that are directly connected to the server. However, traffic generated by file transfers is not considered unless files were sent using the in-band method.
    Author:
    Gaston Dombiak
    • Constructor Detail

      • ServerTrafficCounter

        public ServerTrafficCounter()
    • Method Detail

      • initStatistics

        public static void initStatistics()
        Creates and adds statistics to statistic manager.
      • wrapInputStream

        public static InputStream wrapInputStream​(InputStream originalStream)
        Wraps the specified input stream to count the number of bytes that were read.
        Parameters:
        originalStream - the input stream to wrap.
        Returns:
        The wrapped input stream over the original stream.
      • wrapOutputStream

        public static OutputStream wrapOutputStream​(OutputStream originalStream)
        Wraps the specified output stream to count the number of bytes that were written.
        Parameters:
        originalStream - the output stream to wrap.
        Returns:
        The wrapped output stream over the original stream.
      • wrapReadableChannel

        public static ReadableByteChannel wrapReadableChannel​(ReadableByteChannel originalChannel)
        Wraps the specified readable channel to count the number of bytes that were read.
        Parameters:
        originalChannel - the readable byte channel to wrap.
        Returns:
        The wrapped readable channel over the original readable channel .
      • wrapWritableChannel

        public static WritableByteChannel wrapWritableChannel​(WritableByteChannel originalChannel)
        Wraps the specified writable channel to count the number of bytes that were written.
        Parameters:
        originalChannel - the writable byte channel to wrap.
        Returns:
        The wrapped writable channel over the original writable channel .
      • incrementIncomingCounter

        public static void incrementIncomingCounter​(long delta)
        Increments the counter of read bytes by delta.
        Parameters:
        delta - the delta of bytes that were read.
      • incrementOutgoingCounter

        public static void incrementOutgoingCounter​(long delta)
        Increments the counter of written bytes by delta.
        Parameters:
        delta - the delta of bytes that were written.