Version 4.10.0

hirondelle.web4j.webmaster
Class PerformanceSnapshot

Object
  extended by hirondelle.web4j.webmaster.PerformanceSnapshot

public final class PerformanceSnapshot
extends Object

Statistics on server response time.

This class uses the metaphor of a 'photographic exposure' of, say, 10 minutes, whereby response times for a specific time interval are grouped together in a single bin, and average and maximum response times for that interval are derived for that group.

A particular PerformanceSnapshot is used only if its 'exposure time' has not yet ended. A typical 'exposure' lasts a few minutes. (See PerformanceMonitor and the web.xml of the example application for more information.) By inspecting the return value of getEndTime(), the caller determines if a PerformanceSnapshot object can still be used, or if a new PerformanceSnapshot object must be created for the 'next exposure'.

This class is immutable. In particular, addResponseTime(long, java.lang.String) returns a new object, instead of changing the state of an existing one.


Constructor Summary
PerformanceSnapshot(Integer aExposureTime)
           
 
Method Summary
 PerformanceSnapshot addResponseTime(long aResponseTime, String aURL)
          Return a new PerformanceSnapshot whose state reflects an additional data point.
 boolean equals(Object aThat)
           
static PerformanceSnapshot forGapInActivity(PerformanceSnapshot aCurrentSnapshot)
          Return a PerformanceSnapshot having no activity.
 Long getAvgResponseTime()
          Return the average response time recorded during this snapshot.
 Date getEndTime()
          Return the time that this snapshot will 'end'.
 Integer getExposureTime()
          Return the exposure time in minutes, as passed to the constructor.
 Long getMaxResponseTime()
          Return the maximum response time recorded during this snapshot.
 Integer getNumRequests()
          Return the number of server requests this snapshot has recorded.
 String getURLWithMaxResponseTime()
          Return the URL of the request responsible for getMaxResponseTime().
 int hashCode()
           
 String toString()
          Intended for debugging only.
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PerformanceSnapshot

public PerformanceSnapshot(Integer aExposureTime)
Parameters:
aExposureTime - number of minutes to gather statistics ; see web.xml for more information.
Method Detail

forGapInActivity

public static PerformanceSnapshot forGapInActivity(PerformanceSnapshot aCurrentSnapshot)
Return a PerformanceSnapshot having no activity. Such objects are used to explicitly 'fill in the gaps' during periods of no activity.

The returned object has the same exposure time as aCurrentSnapshot. Its end time is taken as aCurrentSnapshot.getEndTime(), plus the exposure time. All other items are 0 or empty.


addResponseTime

public PerformanceSnapshot addResponseTime(long aResponseTime,
                                           String aURL)
Return a new PerformanceSnapshot whose state reflects an additional data point.

Parameters:
aResponseTime - response time of a particular server request.
aURL - URL of the underlying request.

getEndTime

public Date getEndTime()
Return the time that this snapshot will 'end'. After this time, a new PerformanceSnapshot must be created by the caller (using the constructor).


getNumRequests

public Integer getNumRequests()
Return the number of server requests this snapshot has recorded.

If a page contains two images, for example, the server will likely count 3 requests, not 1 (one page and two images).


getAvgResponseTime

public Long getAvgResponseTime()
Return the average response time recorded during this snapshot.


getMaxResponseTime

public Long getMaxResponseTime()
Return the maximum response time recorded during this snapshot.


getExposureTime

public Integer getExposureTime()
Return the exposure time in minutes, as passed to the constructor.


getURLWithMaxResponseTime

public String getURLWithMaxResponseTime()
Return the URL of the request responsible for getMaxResponseTime().


toString

public String toString()
Intended for debugging only.

Overrides:
toString in class Object

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

Version 4.10.0

Copyright Hirondelle Systems. Published October 19, 2013 - User Guide - All Docs.