ch.elca.el4j.util.socketstatistics
Class ConnectionStatistics

java.lang.Object
  extended by ch.elca.el4j.util.socketstatistics.ConnectionStatistics
All Implemented Interfaces:
Comparable<ConnectionStatistics>

public class ConnectionStatistics
extends Object
implements Comparable<ConnectionStatistics>

Keeps statistics of one (open / closed) socket connection.

Author:
Jonas Hauenstein (JHN)
File-location:
ConnectionStatistics
Last check-in date:
2009-11-13 16:36:10 +0100 (Fr, 13. Nov 2009) by jonasha for revision 3990

Constructor Summary
ConnectionStatistics(long socketID)
          Constructor.
 
Method Summary
 void addbytesrecv(int nrofbytes)
          Add a certain amounts of received bytes to socket stats.
 void addbytessent(int nrofbytes)
          Add a certain amounts of sent bytes to socket stats.
 int compareTo(ConnectionStatistics o)
          Compare using destroyed / closed date of socket / ConnectionStatics.
 boolean equals(Object o)
           
 long getBytesReceived()
          Getter for number of received bytes.
 long getBytesSent()
          Getter for number of sent bytes.
 String getCreatedDate()
          External getter for sockets creation date.
protected  Date getCreatedDateInt()
          Internal getter for sockets creation date.
 String getDestroyedDate()
          External getter for sockets destroyed / close date.
protected  Date getDestroyedDateInt()
          Internal getter for sockets destroyed / close date.
 int getLocalPort()
          Getter for sockets local port.
 String getRemoteAdress()
          Getter for sockets remote address.
 int getRemotePort()
          Getter for sockets remote port.
 long getSocketID()
          Getter for sockets id.
protected  String getStatistics()
          Return stats of socket as string.
protected  String getStatisticsCSV()
          Return stats of socket as string in csv format.
 int hashCode()
           
 void setDestroyed()
          Mark monitored socket as closed / destroyed.
protected  void setDestroyedDateInt()
          Sets socket as destroyed / closed with date = now.
 void setLocalPort(int lp)
          Setter for sockets local port.
 void setRemoteAdress(InetAddress ra)
          Setter for sockets remote address.
 void setRemotePort(int rp)
          Setter for sockets remote port.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionStatistics

public ConnectionStatistics(long socketID)
Constructor.

Parameters:
socketID - (unique) id to be assigned to socket
Method Detail

addbytessent

public void addbytessent(int nrofbytes)
Add a certain amounts of sent bytes to socket stats.

Parameters:
nrofbytes - number of sent bytes

addbytesrecv

public void addbytesrecv(int nrofbytes)
Add a certain amounts of received bytes to socket stats.

Parameters:
nrofbytes - number of received bytes

getBytesReceived

public long getBytesReceived()
Getter for number of received bytes.

Returns:
total number of bytes received on socket

getBytesSent

public long getBytesSent()
Getter for number of sent bytes.

Returns:
total number of bytes sent on socket

setRemoteAdress

public void setRemoteAdress(InetAddress ra)
Setter for sockets remote address.

Parameters:
ra - sockets remote address

getRemoteAdress

public String getRemoteAdress()
Getter for sockets remote address. Using string to guarantee compatibility to MXBeans

Returns:
sockets remote address

setRemotePort

public void setRemotePort(int rp)
Setter for sockets remote port.

Parameters:
rp - sockets remote port

getRemotePort

public int getRemotePort()
Getter for sockets remote port.

Returns:
sockets remote port

setLocalPort

public void setLocalPort(int lp)
Setter for sockets local port.

Parameters:
lp - sockets local port

getLocalPort

public int getLocalPort()
Getter for sockets local port.

Returns:
sockets local port

setDestroyed

public void setDestroyed()
Mark monitored socket as closed / destroyed.


getDestroyedDate

public String getDestroyedDate()
External getter for sockets destroyed / close date. Using string to guarantee compatibility to MXBeans

Returns:
string of date when socket was destroyed / closed

getDestroyedDateInt

protected Date getDestroyedDateInt()
Internal getter for sockets destroyed / close date. Returns date object

Returns:
date when socket was destroyed / closed

setDestroyedDateInt

protected void setDestroyedDateInt()
Sets socket as destroyed / closed with date = now.


getCreatedDate

public String getCreatedDate()
External getter for sockets creation date. Using string to guarantee compatibility to MXBeans

Returns:
string of date when socket was created

getCreatedDateInt

protected Date getCreatedDateInt()
Internal getter for sockets creation date. Returns date object

Returns:
date when socket was created

getSocketID

public long getSocketID()
Getter for sockets id.

Returns:
sockets unique id

getStatistics

protected String getStatistics()
Return stats of socket as string.

Returns:
stats of socket

getStatisticsCSV

protected String getStatisticsCSV()
Return stats of socket as string in csv format.

Returns:
stats of socket

compareTo

public int compareTo(ConnectionStatistics o)
Compare using destroyed / closed date of socket / ConnectionStatics. First hand sort order is destruction ascending date. Open sockets are sorted among each other by creation date.

Specified by:
compareTo in interface Comparable<ConnectionStatistics>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object


Copyright © 2005-2011 ELCA. All Rights Reserved.