org.objectweb.cjdbc.controller.monitoring
Class SQLMonitoring

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.monitoring.Monitoring
      extended byorg.objectweb.cjdbc.controller.monitoring.SQLMonitoring
All Implemented Interfaces:
XmlComponent

public class SQLMonitoring
extends Monitoring

This class implements a SQL monitoring module.

Version:
1.0
Author:
Emmanuel Cecchet

Field Summary
private  boolean defaultRule
           
private static Trace logger
           
private  java.util.ArrayList ruleList
           
private  java.util.Hashtable statList
           
 
Fields inherited from class org.objectweb.cjdbc.controller.monitoring.Monitoring
active
 
Fields inherited from interface org.objectweb.cjdbc.common.xml.XmlComponent
DOCTYPE_CONTROLLER, DOCTYPE_DB, XML_VERSION
 
Constructor Summary
SQLMonitoring(java.lang.String vdbName)
          Create a SQLMonitoring object.
 
Method Summary
 void addRule(SQLMonitoringRule rule)
          Add a rule to the list.
 void cleanStats()
          Clean the content of statistics, to avoid memory problems.
 void dumpAllStatsInformation()
          Dump all stats using the current logger (INFO level).
 java.lang.String[][] getAllStatsInformation()
          Return all stats information in the form of a String
 boolean getDefaultRule()
          Get the default monitoring rule
 java.util.ArrayList getRuleList()
           
 Stats getStatForRequest(AbstractRequest request)
          Retrieve the stat corresponding to a request and create it if it does not exist.
 java.lang.String getXmlImpl()
          Get implementation information
 void logCacheHit(AbstractRequest request)
          Log a cache hit for the given request.
 void logError(AbstractRequest request)
          Log an error for the given request.
 void logRequestTime(AbstractRequest request, long time)
          Log the time elapsed to execute the given request.
private  java.lang.String monitorRequestRule(AbstractRequest request)
          Check the rule list to check of this request should be monitored or not.
 void resetRequestStat(AbstractRequest request)
          Reset the stats associated to a request.
 void setDefaultRule(boolean monitoring)
          Defines the default rule
 
Methods inherited from class org.objectweb.cjdbc.controller.monitoring.Monitoring
getXml, isActive, setActive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

statList

private java.util.Hashtable statList

ruleList

private java.util.ArrayList ruleList

defaultRule

private boolean defaultRule

logger

private static Trace logger
Constructor Detail

SQLMonitoring

public SQLMonitoring(java.lang.String vdbName)
Create a SQLMonitoring object.

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

cleanStats

public void cleanStats()
Description copied from class: Monitoring
Clean the content of statistics, to avoid memory problems.

Specified by:
cleanStats in class Monitoring
See Also:
Monitoring.cleanStats()

logRequestTime

public final void 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

logError

public final void logError(AbstractRequest request)
Log an error for the given request.

Parameters:
request - the request that failed to execute

logCacheHit

public final void logCacheHit(AbstractRequest request)
Log a cache hit for the given request.

Parameters:
request - the request that failed to execute

resetRequestStat

public final void resetRequestStat(AbstractRequest request)
Reset the stats associated to a request.

Parameters:
request - the request to reset

getStatForRequest

public final Stats 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

getAllStatsInformation

public java.lang.String[][] getAllStatsInformation()
Return all stats information in the form of a String

Specified by:
getAllStatsInformation in class Monitoring
Returns:
stats information

dumpAllStatsInformation

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

Specified by:
dumpAllStatsInformation in class Monitoring

getDefaultRule

public boolean getDefaultRule()
Get the default monitoring rule

Returns:
true if default is monitoring enabled

setDefaultRule

public void setDefaultRule(boolean monitoring)
Defines the default rule

Parameters:
monitoring - true if on, false is off

addRule

public void addRule(SQLMonitoringRule rule)
Add a rule to the list.

Parameters:
rule - the rule to add

monitorRequestRule

private java.lang.String monitorRequestRule(AbstractRequest request)
Check the rule list to check of this request should be monitored or not.

Parameters:
request - the query to look for
Returns:
the SQL query to monitor or null if monitoring is off for this request

getRuleList

public java.util.ArrayList getRuleList()
Returns:
Returns the ruleList.

getXmlImpl

public java.lang.String getXmlImpl()
Description copied from class: Monitoring
Get implementation information

Specified by:
getXmlImpl in class Monitoring
See Also:
XmlComponent.getXml()


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.