net.sf.cindy.filter
Class StatisticFilter

java.lang.Object
  extended by net.sf.cindy.SessionFilterAdapter
      extended by net.sf.cindy.filter.StatisticFilter
All Implemented Interfaces:
SessionFilter

public class StatisticFilter
extends SessionFilterAdapter

Statistic filter.

Version:
$id$
Author:
Roger Chen

Constructor Summary
StatisticFilter()
          Construct a statistic filter monitor all sessions.
StatisticFilter(Session session)
          Construct a statistic filter monitor special session.
 
Method Summary
 double getAvgReceiveSpeed()
          Get average receive speed, in byte/s.
 double getAvgSendSpeed()
          Get average send speed, in byte/s.
 long getElapsedTime()
          Get elapsed time after session started and before session closed, in ms.
 long getReceivedBytes()
          Get received bytes count.
 double getReceiveSpeed()
          Get instantaneous receive speed, in byte/s.
 double getSendSpeed()
          Get instantaneous send speed, in byte/s.
 long getSentBytes()
          Get sent bytes count.
 boolean isStopped()
           
 void packetReceived(SessionFilterChain filterChain, Packet packet)
          Session received a packet.
 void packetSent(SessionFilterChain filterChain, Packet packet)
          Session sent a packet.
 void reset()
          Reset.
 void sessionClosed(SessionFilterChain filterChain)
          Session have closed.
 void sessionStarted(SessionFilterChain filterChain)
          Session have started.
 void start()
           
 void stop()
           
 
Methods inherited from class net.sf.cindy.SessionFilterAdapter
exceptionCaught, objectReceived, objectSent, packetSend, sessionTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatisticFilter

public StatisticFilter()
Construct a statistic filter monitor all sessions.


StatisticFilter

public StatisticFilter(Session session)
Construct a statistic filter monitor special session.

Parameters:
session - monitor special session
Method Detail

isStopped

public boolean isStopped()

start

public void start()

stop

public void stop()

getAvgReceiveSpeed

public double getAvgReceiveSpeed()
Get average receive speed, in byte/s.

Returns:
average receive speed.

getAvgSendSpeed

public double getAvgSendSpeed()
Get average send speed, in byte/s.

Returns:
average send speed.

getElapsedTime

public long getElapsedTime()
Get elapsed time after session started and before session closed, in ms.

Returns:
elapsed time

getReceivedBytes

public long getReceivedBytes()
Get received bytes count. If session restart, the value will reset to 0.

Returns:
received bytes count

getSentBytes

public long getSentBytes()
Get sent bytes count. If session restart, the value will reset to 0.

Returns:
sent bytes count

getReceiveSpeed

public double getReceiveSpeed()
Get instantaneous receive speed, in byte/s.

Returns:
received speed

getSendSpeed

public double getSendSpeed()
Get instantaneous send speed, in byte/s.

Returns:
send speed

reset

public void reset()
Reset.


sessionStarted

public void sessionStarted(SessionFilterChain filterChain)
                    throws java.lang.Exception
Description copied from interface: SessionFilter
Session have started.

Specified by:
sessionStarted in interface SessionFilter
Overrides:
sessionStarted in class SessionFilterAdapter
Parameters:
filterChain - session filter chain
Throws:
java.lang.Exception - any exception

sessionClosed

public void sessionClosed(SessionFilterChain filterChain)
                   throws java.lang.Exception
Description copied from interface: SessionFilter
Session have closed.

Specified by:
sessionClosed in interface SessionFilter
Overrides:
sessionClosed in class SessionFilterAdapter
Parameters:
filterChain - session filter chain
Throws:
java.lang.Exception - any exception

packetReceived

public void packetReceived(SessionFilterChain filterChain,
                           Packet packet)
                    throws java.lang.Exception
Description copied from interface: SessionFilter
Session received a packet.

Specified by:
packetReceived in interface SessionFilter
Overrides:
packetReceived in class SessionFilterAdapter
Parameters:
filterChain - session filter chain
packet - the received packet
Throws:
java.lang.Exception - any exception

packetSent

public void packetSent(SessionFilterChain filterChain,
                       Packet packet)
                throws java.lang.Exception
Description copied from interface: SessionFilter
Session sent a packet. This event will be dispatched in the reversed order. The packet's position will not be updated.

Specified by:
packetSent in interface SessionFilter
Overrides:
packetSent in class SessionFilterAdapter
Parameters:
filterChain - session filter chain
packet - the sent packet
Throws:
java.lang.Exception - any exception