Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.controller.monitoring.SQLMonitoring Class Reference

Inheritance diagram for org.objectweb.cjdbc.controller.monitoring.SQLMonitoring:

Inheritance graph
[legend]
Collaboration diagram for org.objectweb.cjdbc.controller.monitoring.SQLMonitoring:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SQLMonitoring (String vdbName)
void cleanStats ()
final void logRequestTime (AbstractRequest request, long time)
final void logError (AbstractRequest request)
final void logCacheHit (AbstractRequest request)
final void resetRequestStat (AbstractRequest request)
final Stats getStatForRequest (AbstractRequest request)
String[][] getAllStatsInformation ()
void dumpAllStatsInformation ()
boolean getDefaultRule ()
void setDefaultRule (boolean monitoring)
void addRule (SQLMonitoringRule rule)
ArrayList getRuleList ()
String getXmlImpl ()

Detailed Description

This class implements a SQL monitoring module.

Author:
Emmanuel Cecchet
Version:
1.0

Definition at line 43 of file SQLMonitoring.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.SQLMonitoring String  vdbName  ) 
 

Create a SQLMonitoring object.

Parameters:
vdbName name of the virtual database to be used by the logger

Definition at line 56 of file SQLMonitoring.java.

00057   {
00058     statList = new Hashtable();
00059     ruleList = new ArrayList();
00060     logger = Trace.getLogger("org.objectweb.cjdbc.controller.monitoring."
00061         + vdbName);
00062   }


Member Function Documentation

void org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.addRule SQLMonitoringRule  rule  ) 
 

Add a rule to the list.

Parameters:
rule the rule to add

Definition at line 218 of file SQLMonitoring.java.

00219   {
00220     this.ruleList.add(rule);
00221   }

void org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.cleanStats  )  [virtual]
 

See also:
org.objectweb.cjdbc.controller.monitoring.Monitoring.cleanStats()

Implements org.objectweb.cjdbc.controller.monitoring.Monitoring.

Definition at line 67 of file SQLMonitoring.java.

00068   {
00069     statList.clear();
00070   }

void org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.dumpAllStatsInformation  )  [virtual]
 

Dump all stats using the current logger (INFO level).

Implements org.objectweb.cjdbc.controller.monitoring.Monitoring.

Definition at line 177 of file SQLMonitoring.java.

References org.objectweb.cjdbc.common.util.Stats.singleLineDisplay().

00178   {
00179     if (logger.isInfoEnabled())
00180     {
00181       for (Iterator iter = statList.values().iterator(); iter.hasNext();)
00182       {
00183         Stats stat = (Stats) iter.next();
00184         logger.info(stat.singleLineDisplay());
00185       }
00186     }
00187   }

String [][] org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getAllStatsInformation  )  [virtual]
 

Return all stats information in the form of a String

Returns:
stats information

Implements org.objectweb.cjdbc.controller.monitoring.Monitoring.

Definition at line 161 of file SQLMonitoring.java.

References org.objectweb.cjdbc.common.util.Stats.toStringTable().

Referenced by org.objectweb.cjdbc.controller.monitoring.datacollector.DataCollector.retrieveSQLStats().

00162   {
00163     Collection values = statList.values();
00164     String[][] result = new String[values.size()][];
00165     int i = 0;
00166     for (Iterator iter = values.iterator(); iter.hasNext(); i++)
00167     {
00168       Stats stat = (Stats) iter.next();
00169       result[i] = stat.toStringTable();
00170     }
00171     return result;
00172   }

boolean org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getDefaultRule  ) 
 

Get the default monitoring rule

Returns:
true if default is monitoring enabled

Definition at line 198 of file SQLMonitoring.java.

Referenced by org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getXmlImpl().

00199   {
00200     return defaultRule;
00201   }

ArrayList org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getRuleList  ) 
 

Returns:
Returns the ruleList.

Definition at line 260 of file SQLMonitoring.java.

00261   {
00262     return ruleList;
00263   }

final Stats org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getStatForRequest AbstractRequest  request  ) 
 

Retrieve the stat corresponding to a request and create it if it does not exist.

Parameters:
request the request to look for
Returns:
corresponding stat or null if a rule does not authorize this request to be monitored

Definition at line 140 of file SQLMonitoring.java.

Referenced by org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.logCacheHit(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.logError(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.logRequestTime(), and org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.resetRequestStat().

00141   {
00142     String sql = monitorRequestRule(request);
00143     if (sql == null)
00144       return null;
00145 
00146     // Note that the Hashtable is synchronized
00147     Stats stat = (Stats) statList.get(sql);
00148     if (stat == null)
00149     { // No entry for this query, create a new Stats entry
00150       stat = new Stats(sql);
00151       statList.put(sql, stat);
00152     }
00153     return stat;
00154   }

String org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getXmlImpl  )  [virtual]
 

See also:
org.objectweb.cjdbc.common.xml.XmlComponent.getXml()

Implements org.objectweb.cjdbc.controller.monitoring.Monitoring.

Definition at line 268 of file SQLMonitoring.java.

References org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getDefaultRule(), and org.objectweb.cjdbc.controller.monitoring.SQLMonitoringRule.getXml().

00269   {
00270     String info = "<" + DatabasesXmlTags.ELT_SQLMonitoring + " "
00271         + DatabasesXmlTags.ATT_defaultMonitoring + "=\"";
00272     info += getDefaultRule();
00273     info += "\">";
00274     for (int i = 0; i < ruleList.size(); i++)
00275     {
00276       SQLMonitoringRule rule = (SQLMonitoringRule) ruleList.get(i);
00277       info += rule.getXml();
00278     }
00279     info += "</" + DatabasesXmlTags.ELT_SQLMonitoring + ">";
00280     return info;
00281   }

final void org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.logCacheHit AbstractRequest  request  ) 
 

Log a cache hit for the given request.

Parameters:
request the request that failed to execute

Definition at line 109 of file SQLMonitoring.java.

References org.objectweb.cjdbc.common.util.Stats.getName(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getStatForRequest(), and org.objectweb.cjdbc.common.util.Stats.incrementCacheHit().

00110   {
00111     Stats stat = getStatForRequest(request);
00112     if (stat == null)
00113       return;
00114     stat.incrementCacheHit();
00115     if (logger.isDebugEnabled())
00116       logger.debug("Cache hit " + stat.getName());
00117   }

final void org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.logError AbstractRequest  request  ) 
 

Log an error for the given request.

Parameters:
request the request that failed to execute

Definition at line 94 of file SQLMonitoring.java.

References org.objectweb.cjdbc.common.util.Stats.getName(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getStatForRequest(), and org.objectweb.cjdbc.common.util.Stats.incrementError().

00095   {
00096     Stats stat = getStatForRequest(request);
00097     if (stat == null)
00098       return;
00099     stat.incrementError();
00100     if (logger.isDebugEnabled())
00101       logger.debug("ERROR " + stat.getName());
00102   }

final void org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.logRequestTime AbstractRequest  request,
long  time
 

Log the time elapsed to execute the given request.

Parameters:
request the request executed
time time elapsed to execute this request

Definition at line 78 of file SQLMonitoring.java.

References org.objectweb.cjdbc.common.util.Stats.getName(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getStatForRequest(), org.objectweb.cjdbc.common.util.Stats.incrementCount(), and org.objectweb.cjdbc.common.util.Stats.updateTime().

00079   {
00080     Stats stat = getStatForRequest(request);
00081     if (stat == null)
00082       return;
00083     stat.incrementCount();
00084     stat.updateTime(time);
00085     if (logger.isDebugEnabled())
00086       logger.debug(time + " " + stat.getName());
00087   }

final void org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.resetRequestStat AbstractRequest  request  ) 
 

Reset the stats associated to a request.

Parameters:
request the request to reset

Definition at line 124 of file SQLMonitoring.java.

References org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getStatForRequest(), and org.objectweb.cjdbc.common.util.Stats.reset().

00125   {
00126     Stats stat = getStatForRequest(request);
00127     if (stat == null)
00128       return;
00129     stat.reset();
00130   }

void org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.setDefaultRule boolean  monitoring  ) 
 

Defines the default rule

Parameters:
monitoring true if on, false is off

Definition at line 208 of file SQLMonitoring.java.

00209   {
00210     this.defaultRule = monitoring;
00211   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:04:21 2005 for C-JDBC by  doxygen 1.3.9.1