|
Version 3.10.0
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objecthirondelle.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.
<init-param>
<param-name>BadResponseDetector</param-name>
<param-value>http://www.blah.com/whatever.do, 5, 30</param-value>
</init-param>
The BadRequestDetector setting specifies 3 items separated by a comma:
Pings begin shortly after this filter is first initialized. Each ping does a GET for the target URL in a background thread. These ping operations look for two kinds of problems :
If a problem is detected, a short TroubleTicket
describing the problem is sent to the TroubleTicketMailingList
recipients configured in web.xml.
Applications may not respond normally to HTTP requests for various reasons :
This class runs as part of your application. Of course, it's unable to detect when your app itself is not running. However, it's still quite useful, and will catch many important errors. If desired, you can use sites such as SiteUptime.com to monitor your site using external tools.
| 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 Filterpublic void destroy()
destroy in interface Filter
public void doFilter(ServletRequest aRequest,
ServletResponse aResponse,
FilterChain aChain)
throws IOException,
ServletException
doFilter in interface FilterIOException
ServletExceptionpublic 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 3.10.0
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||