Version 4.10.0

hirondelle.web4j.webmaster
Class PerformanceMonitor

Object
  extended by hirondelle.web4j.webmaster.PerformanceMonitor
All Implemented Interfaces:
Filter

public final class PerformanceMonitor
extends Object
implements Filter

Compile simple performance statistics, and use periodic pings to detect trouble.

See web.xml for more information on how to configure this Filter.

Performance Statistics

This class stores a Collection of PerformanceSnapshot objects in memory (not in a database).

The presentation of these performance statistics in a JSP is always "one behind" this class. This Filter examines the response time of each fully processed request. Any JSP presenting the response times, however, is not fully processed from the point of view of this filter, and has not yet contributed to the statistics.

It is important to note that Filter objects must be designed to operate safely in a multi-threaded environment. Using the nomenclature of Effective Java, this class is 'conditionally thread safe' : the responsibility for correct operation in a multi-threaded environment is shared between this class and its caller. See getPerformanceHistory() for more information.

If desired, you can use also external tools such as SiteUptime.com to monitor your site.


Constructor Summary
PerformanceMonitor()
           
 
Method Summary
 void destroy()
          This implementation does nothing.
 void doFilter(ServletRequest aRequest, ServletResponse aResponse, FilterChain aChain)
          Calculate server response time, and store relevant statistics in memory.
static List<PerformanceSnapshot> getPerformanceHistory()
          Return statistics on recent application performance.
 void init(FilterConfig aFilterConfig)
          Read in the configuration of this filter from web.xml.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerformanceMonitor

public PerformanceMonitor()
Method Detail

init

public void init(FilterConfig aFilterConfig)
Read in the configuration of this filter from web.xml.

The config is validated, gathering of statistics is begun, and any periodic ping operations are initialized.

Specified by:
init in interface Filter

destroy

public void destroy()
This implementation does nothing.

Specified by:
destroy in interface Filter

doFilter

public void doFilter(ServletRequest aRequest,
                     ServletResponse aResponse,
                     FilterChain aChain)
              throws IOException,
                     ServletException
Calculate server response time, and store relevant statistics in memory.

Specified by:
doFilter in interface Filter
Throws:
IOException
ServletException

getPerformanceHistory

public static List<PerformanceSnapshot> getPerformanceHistory()
Return statistics on recent application performance.

A static method is the only way an Action can access this data, since it has no access to the Filter object itself (which is built by the container).

The typical task for the caller is iteration over the return value. The caller must synchronize this iteration, by obtaining the lock on the return value. The typical use case of this method is :

   List history = PerformanceMonitor.getPerformanceHistory();
   synchronized(history) {
     for(PerformanceSnapshot snapshot : history){
       //..elided
     }
   }
   


Version 4.10.0

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