|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.web4j.webmaster.PerformanceMonitor
public final class PerformanceMonitor
Compile simple performance statistics, and use periodic pings to detect trouble.
See web.xml for more information on how to configure this Filter
.
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 |
---|
public PerformanceMonitor()
Method Detail |
---|
public void init(FilterConfig aFilterConfig)
The config is validated, gathering of statistics is begun, and any periodic ping operations are initialized.
init
in interface Filter
public void destroy()
destroy
in interface Filter
public void doFilter(ServletRequest aRequest, ServletResponse aResponse, FilterChain aChain) throws IOException, ServletException
doFilter
in interface Filter
IOException
ServletException
public static List<PerformanceSnapshot> getPerformanceHistory()
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 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |