anon.infoservice
Class PerformanceEntry

java.lang.Object
  extended by anon.infoservice.AbstractDatabaseEntry
      extended by anon.infoservice.PerformanceEntry
All Implemented Interfaces:
IXMLEncodable

public class PerformanceEntry
extends AbstractDatabaseEntry
implements IXMLEncodable

A PerformanceEntry stores various performance-related data such as average speed or delay about a certain MixCascade.

Author:
Christian Banse

Nested Class Summary
static class PerformanceEntry.Bound
           
static class PerformanceEntry.PerformanceAttributeEntry
          An entry that holds values of performance attributes.
private static class PerformanceEntry.PerformanceAttributeFloatingTimeEntry
          The floating time entry.
static class PerformanceEntry.StabilityAttributes
           
 
Field Summary
private static java.lang.String[] ATTRIBUTES
          Text representation of the performance attributes.
private static double BOUND_ROUNDING
          Remove the worst x% results.
static int[][] BOUNDARIES
          The boundaries used to calculate the speed and delay bounds.
static int DELAY
          Delay attribute.
static long LAST_TEST_DATA_TTL
          Time-to-live of the last-test-data display.
private  boolean m_bPassive
           
private  java.util.Calendar m_current
          A calendar used for date calculations.
private  PerformanceEntry.PerformanceAttributeEntry[][][] m_entries
          The attribute entries.
private  PerformanceEntry.PerformanceAttributeFloatingTimeEntry[] m_floatingTimeEntries
          The floating time entry.
private  int[] m_lastTestAverage
          The average entries of the last test.
private  long m_lastTestTime
          The time of the last performed test.
private  long m_lastUpdate
          The time of the last update.
private  long m_serial
          The serial of the database entry.
private  PerformanceEntry.StabilityAttributes m_stabilityAttributes
           
private  java.lang.String m_strCascadeId
          The id of the associated cascade.
static long ONE_DAY_TIMEOUT
           
static int PACKETS
          Current users attribute.
private static int PERFORMANCE_ENTRY_TTL
          Time-to-live of the performance entries.
static int SPEED
          Speed attribute.
static int USERS
          Current users attribute.
static long WEEK_SEVEN_DAYS_TIMEOUT
           
private static java.lang.String XML_ATTR_ID
          The cascade id attribute name.
static java.lang.String XML_ELEMENT_CONTAINER_NAME
          The entry's container XML element name.
private static java.lang.String XML_ELEMENT_DATA
          The data XML element name.
static java.lang.String XML_ELEMENT_NAME
          The XML element name.
 
Fields inherited from class anon.infoservice.AbstractDatabaseEntry
XML_ATTR_LAST_UPDATE, XML_LAST_UPDATE
 
Fields inherited from interface anon.util.IXMLEncodable
FIELD_XML_ELEMENT_CONTAINER_NAME, FIELD_XML_ELEMENT_NAME, XML_ATTR_LANGUAGE, XML_ATTR_VERSION
 
Constructor Summary
PerformanceEntry(org.w3c.dom.Element a_entry)
          Constructs a new PerformanceEntry from its XML representation.
PerformanceEntry(java.lang.String a_strCascadeId)
          Constructs a new PerformanceEntry for the given MixCascade.
PerformanceEntry(java.lang.String a_strCascadeId, boolean a_bPassive)
          Constructs a new PerformanceEntry for the given MixCascade.
 
Method Summary
 int addData(int a_attribute, java.util.Hashtable a_data)
          Adds a hashtable of values into the entry array.
private  PerformanceEntry.PerformanceAttributeEntry addPerformanceAttributeEntry(int a_attribute, long a_timestamp, int a_value, boolean a_bImport)
           
 java.lang.String delayToHTML(int day)
          Returns the delay values of a specified day as HTML table.
 int getAverage(int a_attribute)
          Returns the average value of the give attribute.
 int getBestBound(int a_attribute)
          Calculates (if used by the info service) and returns the best bound value of the given attribute.
 PerformanceEntry.Bound getBound(int a_attribute)
          Calculates (if used by the info service) and returns the bound value of the given attribute.
private  long getDayTimestamp(int a_attribute, int a_dayOfWeek)
          Determines the day timestamp of the oldest entry of specified performance attribute.
 java.lang.String getId()
          Returns a unique ID for a database entry.
 int getLastTestAverage(int a_attribute)
          Returns the average value from the last performed test.
 long getLastTestTime()
          Returns the time of the last test.
 long getLastUpdate()
          Returns the time in milliseconds when this db entry was created from the origin instance.
 PerformanceEntry.StabilityAttributes getStabilityAttributes()
          Returns errors resets, unknown requests and total requests for floating entries.
 long getVersionNumber()
          Returns version number which is used to determine the more recent infoservice entry, if two entries are compared (higher version number -> more recent entry).
 PerformanceEntry.PerformanceAttributeEntry importValue(int a_attribute, long a_timestamp, int a_value)
          Imports a value into the entry array.
 void setBestBound(int a_attribute, int a_lValue)
          Sets the best bound value.
 void setBound(int a_attribute, PerformanceEntry.Bound a_lValue)
          Sets the bound value.
 void setStabilityAttributes(PerformanceEntry.StabilityAttributes a_attributes)
           
 java.lang.String speedToHTML(int day)
          Returns the speed values of a specified day as HTML table.
private  java.lang.String toHTML(int a_attribute, java.lang.String a_unit, int a_selectedDay)
          Constructs a HTML table of the specified performance attribute on the a certain day.
 org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
          Return an element that can be appended to the document.
 PerformanceEntry update(PerformanceEntry a_entry)
           
 java.util.Vector updateHourlyPerformanceAttributeEntries(long a_timestamp)
           
 java.lang.String usersToHTML(int day)
          Returns the users values of a specified day as HTML table.
 
Methods inherited from class anon.infoservice.AbstractDatabaseEntry
deletePersistence, getCreationTime, getExpireTime, isNewerThan, isPersistanceDeletionAllowed, isUserDefined, resetCreationTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEEK_SEVEN_DAYS_TIMEOUT

public static final long WEEK_SEVEN_DAYS_TIMEOUT
See Also:
Constant Field Values

ONE_DAY_TIMEOUT

public static final long ONE_DAY_TIMEOUT
See Also:
Constant Field Values

BOUND_ROUNDING

private static final double BOUND_ROUNDING
Remove the worst x% results.

See Also:
Constant Field Values

XML_ELEMENT_CONTAINER_NAME

public static final java.lang.String XML_ELEMENT_CONTAINER_NAME
The entry's container XML element name.

See Also:
Constant Field Values

XML_ELEMENT_NAME

public static final java.lang.String XML_ELEMENT_NAME
The XML element name.

See Also:
Constant Field Values

XML_ELEMENT_DATA

private static final java.lang.String XML_ELEMENT_DATA
The data XML element name.

See Also:
Constant Field Values

XML_ATTR_ID

private static final java.lang.String XML_ATTR_ID
The cascade id attribute name.

See Also:
Constant Field Values

LAST_TEST_DATA_TTL

public static final long LAST_TEST_DATA_TTL
Time-to-live of the last-test-data display.

See Also:
Constant Field Values

PERFORMANCE_ENTRY_TTL

private static final int PERFORMANCE_ENTRY_TTL
Time-to-live of the performance entries.

See Also:
Constant Field Values

SPEED

public static final int SPEED
Speed attribute.

See Also:
Constant Field Values

DELAY

public static final int DELAY
Delay attribute.

See Also:
Constant Field Values

USERS

public static final int USERS
Current users attribute.

See Also:
Constant Field Values

PACKETS

public static final int PACKETS
Current users attribute.

See Also:
Constant Field Values

ATTRIBUTES

private static final java.lang.String[] ATTRIBUTES
Text representation of the performance attributes.


BOUNDARIES

public static final int[][] BOUNDARIES
The boundaries used to calculate the speed and delay bounds.


m_strCascadeId

private java.lang.String m_strCascadeId
The id of the associated cascade.


m_current

private java.util.Calendar m_current
A calendar used for date calculations.


m_lastUpdate

private long m_lastUpdate
The time of the last update.


m_serial

private long m_serial
The serial of the database entry.


m_bPassive

private boolean m_bPassive

m_lastTestTime

private long m_lastTestTime
The time of the last performed test.


m_stabilityAttributes

private PerformanceEntry.StabilityAttributes m_stabilityAttributes

m_entries

private PerformanceEntry.PerformanceAttributeEntry[][][] m_entries
The attribute entries.


m_floatingTimeEntries

private PerformanceEntry.PerformanceAttributeFloatingTimeEntry[] m_floatingTimeEntries
The floating time entry. This structure holds all attribute entries that are not older than a given time (usually 1 hour).


m_lastTestAverage

private int[] m_lastTestAverage
The average entries of the last test.

Constructor Detail

PerformanceEntry

public PerformanceEntry(java.lang.String a_strCascadeId)
Constructs a new PerformanceEntry for the given MixCascade.

Parameters:
a_strCascadeId - The id of the mix cascade.

PerformanceEntry

public PerformanceEntry(java.lang.String a_strCascadeId,
                        boolean a_bPassive)
Constructs a new PerformanceEntry for the given MixCascade.

Parameters:
a_strCascadeId - The id of the mix cascade.
a_bInfoService - Specifies if the caller of this method is an InfoService or the JAP client.

PerformanceEntry

public PerformanceEntry(org.w3c.dom.Element a_entry)
                 throws XMLParseException
Constructs a new PerformanceEntry from its XML representation.

Parameters:
a_entry - The XML data.
Throws:
XMLParseException - If the XML data is invalid.
Method Detail

getId

public java.lang.String getId()
Description copied from class: AbstractDatabaseEntry
Returns a unique ID for a database entry.

Specified by:
getId in class AbstractDatabaseEntry
Returns:
The ID of this database entry.

getLastUpdate

public long getLastUpdate()
Description copied from class: AbstractDatabaseEntry
Returns the time in milliseconds when this db entry was created from the origin instance. Never (!) insert the local creation time here, as this will DoS the InfoServices in an endless loop.

Specified by:
getLastUpdate in class AbstractDatabaseEntry
Returns:
the time in milliseconds when this db entry was created from the origin instance

getVersionNumber

public long getVersionNumber()
Description copied from class: AbstractDatabaseEntry
Returns version number which is used to determine the more recent infoservice entry, if two entries are compared (higher version number -> more recent entry). Never (!) insert the local creation time here, as this will DoS the InfoServices in an endless loop.

Specified by:
getVersionNumber in class AbstractDatabaseEntry
Returns:
The version number for this entry.

getLastTestTime

public long getLastTestTime()
Returns the time of the last test.

Returns:
The time of the last test.

importValue

public PerformanceEntry.PerformanceAttributeEntry importValue(int a_attribute,
                                                              long a_timestamp,
                                                              int a_value)
Imports a value into the entry array.

Parameters:
a_attribute - The performance attribute.
a_timestamp - The time stamp of the value.
a_value - The value itself.

update

public PerformanceEntry update(PerformanceEntry a_entry)

updateHourlyPerformanceAttributeEntries

public java.util.Vector updateHourlyPerformanceAttributeEntries(long a_timestamp)

addPerformanceAttributeEntry

private PerformanceEntry.PerformanceAttributeEntry addPerformanceAttributeEntry(int a_attribute,
                                                                                long a_timestamp,
                                                                                int a_value,
                                                                                boolean a_bImport)

addData

public int addData(int a_attribute,
                   java.util.Hashtable a_data)
Adds a hashtable of values into the entry array.

Parameters:
a_attribute - The performance attribute.
a_data - The data hashtable.
Returns:
The average value of the hashtable.

getLastTestAverage

public int getLastTestAverage(int a_attribute)
Returns the average value from the last performed test.

Parameters:
a_attribute - The performance attribute.
Returns:
The average value from the last performed test.

setStabilityAttributes

public void setStabilityAttributes(PerformanceEntry.StabilityAttributes a_attributes)

setBound

public void setBound(int a_attribute,
                     PerformanceEntry.Bound a_lValue)
Sets the bound value. This should only be used by the PerformanceInfo class in the JAP client.

Parameters:
a_attribute - The performance attribute.
a_lValue - The bound value.
See Also:
PerformanceInfo.getLowestCommonBoundEntry(String)

setBestBound

public void setBestBound(int a_attribute,
                         int a_lValue)
Sets the best bound value. This should only be used by the PerformanceInfo class in the JAP client.

Parameters:
a_attribute - The performance attribute.
a_lValue - The best bound value.
See Also:
PerformanceInfo.getLowestCommonBoundEntry(String)

getBound

public PerformanceEntry.Bound getBound(int a_attribute)
Calculates (if used by the info service) and returns the bound value of the given attribute.

Parameters:
a_attribute - The performance attribute.
Returns:
The bound value of the given attribute.

getStabilityAttributes

public PerformanceEntry.StabilityAttributes getStabilityAttributes()
Returns errors resets, unknown requests and total requests for floating entries.

Returns:

getBestBound

public int getBestBound(int a_attribute)
Calculates (if used by the info service) and returns the best bound value of the given attribute.

Parameters:
a_attribute - The performance attribute.
Returns:
The best bound value of the given attribute.

getAverage

public int getAverage(int a_attribute)
Returns the average value of the give attribute.

Parameters:
a_attribute - The performance attribute.
Returns:
The average value of given attribute.

delayToHTML

public java.lang.String delayToHTML(int day)
Returns the delay values of a specified day as HTML table.

Parameters:
day - The day.
Returns:
The HTML table.

speedToHTML

public java.lang.String speedToHTML(int day)
Returns the speed values of a specified day as HTML table.

Parameters:
day - The day.
Returns:
The HTML table.

usersToHTML

public java.lang.String usersToHTML(int day)
Returns the users values of a specified day as HTML table.

Parameters:
day - The day.
Returns:
The HTML table.

getDayTimestamp

private long getDayTimestamp(int a_attribute,
                             int a_dayOfWeek)
Determines the day timestamp of the oldest entry of specified performance attribute.

Parameters:
a_attribute - The performance attribute.
a_dayOfWeek - The day of the week.
Returns:
The day timestamp.

toHTML

private java.lang.String toHTML(int a_attribute,
                                java.lang.String a_unit,
                                int a_selectedDay)
Constructs a HTML table of the specified performance attribute on the a certain day.

Parameters:
a_attribute - The performance attribute.
a_unit - The unit of the attribute.
a_selectedDay - The day.
Returns:
The HTML table.

toXmlElement

public org.w3c.dom.Element toXmlElement(org.w3c.dom.Document a_doc)
Description copied from interface: IXMLEncodable
Return an element that can be appended to the document. This Method must not change the document in any way!

Specified by:
toXmlElement in interface IXMLEncodable
Parameters:
a_doc - a document
Returns:
the interface as xml element