クラス org.objectweb.cjdbc.controller.monitoring.SQLMonitoring

org.objectweb.cjdbc.controller.monitoring.SQLMonitoringに対する継承グラフ

Inheritance graph
[凡例]
org.objectweb.cjdbc.controller.monitoring.SQLMonitoringのコラボレーション図

Collaboration graph
[凡例]
すべてのメンバ一覧

説明

This class implements a SQL monitoring module.

作者:
Emmanuel Cecchet
バージョン:
1.0

SQLMonitoring.java43 行で定義されています。

Public メソッド

 SQLMonitoring (String vdbName)
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 ()
String getXml ()

Private メソッド

String monitorRequestRule (AbstractRequest request)

Private 変数

Hashtable statList
ArrayList ruleList
boolean defaultRule

Static Private 変数

Trace logger = null


コンストラクタとデストラクタ

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

Create a SQLMonitoring object.

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

SQLMonitoring.java56 行で定義されています。

参照先 org.objectweb.cjdbc.common.log.Trace.getLogger(), と org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.statList.

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


メソッド

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

Add a rule to the list.

引数:
rule the rule to add

SQLMonitoring.java210 行で定義されています。

00211   {
00212     this.ruleList.add(rule);
00213   }

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

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

org.objectweb.cjdbc.controller.monitoring.Monitoringに実装されています.

SQLMonitoring.java169 行で定義されています。

参照先 org.objectweb.cjdbc.common.log.Trace.info(), org.objectweb.cjdbc.common.log.Trace.isInfoEnabled(), org.objectweb.cjdbc.common.util.Stats.singleLineDisplay(), と org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.statList.

00170   {
00171     if (logger.isInfoEnabled())
00172     {
00173       for (Iterator iter = statList.values().iterator(); iter.hasNext();)
00174       {
00175         Stats stat = (Stats) iter.next();
00176         logger.info(stat.singleLineDisplay());
00177       }
00178     }
00179   }

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

Return all stats information in the form of a String

戻り値:
stats information

org.objectweb.cjdbc.controller.monitoring.Monitoringに実装されています.

SQLMonitoring.java153 行で定義されています。

参照先 org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.statList, と org.objectweb.cjdbc.common.util.Stats.toStringTable().

参照元 org.objectweb.cjdbc.controller.monitoring.datacollector.DataCollector.retrieveSQLStats().

00154   {
00155     Collection values = statList.values();
00156     String[][] result = new String[values.size()][];
00157     int i = 0;
00158     for (Iterator iter = values.iterator(); iter.hasNext(); i++)
00159     {
00160       Stats stat = (Stats) iter.next();
00161       result[i] = stat.toStringTable();
00162     }
00163     return result;
00164   }

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

Get the default monitoring rule

戻り値:
true if default is monitoring enabled

SQLMonitoring.java190 行で定義されています。

参照元 org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getXmlImpl().

00191   {
00192     return defaultRule;
00193   }

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

戻り値:
Returns the ruleList.

SQLMonitoring.java252 行で定義されています。

00253   {
00254     return ruleList;
00255   }

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.

引数:
request the request to look for
戻り値:
corresponding stat or null if a rule does not authorize this request to be monitored

SQLMonitoring.java132 行で定義されています。

参照先 org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.monitorRequestRule(), と org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.statList.

参照元 org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.logCacheHit(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.logError(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.logRequestTime(), と org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.resetRequestStat().

00133   {
00134     String sql = monitorRequestRule(request);
00135     if (sql == null)
00136       return null;
00137 
00138     // Note that the Hashtable is synchronized
00139     Stats stat = (Stats) statList.get(sql);
00140     if (stat == null)
00141     { // No entry for this query, create a new Stats entry
00142       stat = new Stats(sql);
00143       statList.put(sql, stat);
00144     }
00145     return stat;
00146   }

String org.objectweb.cjdbc.controller.monitoring.Monitoring.getXml  )  [inherited]
 

参照:
org.objectweb.cjdbc.common.xml.XmlComponent.getXml()

Monitoring.java34 行で定義されています。

参照先 org.objectweb.cjdbc.controller.monitoring.Monitoring.getXmlImpl().

00035   {
00036     StringBuffer info = new StringBuffer();
00037     info.append("<"+DatabasesXmlTags.ELT_Monitoring+">");
00038     info.append(getXmlImpl());
00039     info.append("</"+DatabasesXmlTags.ELT_Monitoring+">");
00040     return info.toString();
00041   }

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

参照:
org.objectweb.cjdbc.common.xml.XmlComponent.getXml()

org.objectweb.cjdbc.controller.monitoring.Monitoringに実装されています.

SQLMonitoring.java260 行で定義されています。

参照先 org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getDefaultRule().

00261   {
00262     String info =
00263       "<"
00264         + DatabasesXmlTags.ELT_SQLMonitoring
00265         + " "
00266         + DatabasesXmlTags.ATT_defaultMonitoring
00267         + "=\"";
00268     info += getDefaultRule();
00269     info += "\">";
00270     for (int i = 0; i < ruleList.size(); i++)
00271     {
00272       SQLMonitoringRule rule = (SQLMonitoringRule) ruleList.get(i);
00273     }
00274     info += "</" + DatabasesXmlTags.ELT_SQLMonitoring + ">";
00275     return info;
00276   }

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

Log a cache hit for the given request.

引数:
request the request that failed to execute

SQLMonitoring.java101 行で定義されています。

参照先 org.objectweb.cjdbc.common.log.Trace.debug(), org.objectweb.cjdbc.common.util.Stats.getName(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getStatForRequest(), org.objectweb.cjdbc.common.util.Stats.incrementCacheHit(), と org.objectweb.cjdbc.common.log.Trace.isDebugEnabled().

00102   {
00103     Stats stat = getStatForRequest(request);
00104     if (stat == null)
00105       return;
00106     stat.incrementCacheHit();
00107     if (logger.isDebugEnabled())
00108       logger.debug("Cache hit " + stat.getName());
00109   }

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

Log an error for the given request.

引数:
request the request that failed to execute

SQLMonitoring.java86 行で定義されています。

参照先 org.objectweb.cjdbc.common.log.Trace.debug(), org.objectweb.cjdbc.common.util.Stats.getName(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getStatForRequest(), org.objectweb.cjdbc.common.util.Stats.incrementError(), と org.objectweb.cjdbc.common.log.Trace.isDebugEnabled().

参照元 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execReadRequest(), org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execReadStoredProcedure(), org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execWriteRequest(), と org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execWriteRequestWithKeys().

00087   {
00088     Stats stat = getStatForRequest(request);
00089     if (stat == null)
00090       return;
00091     stat.incrementError();
00092     if (logger.isDebugEnabled())
00093       logger.debug("ERROR " + stat.getName());
00094   }

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

Log the time elapsed to execute the given request.

引数:
request the request executed
time time elapsed to execute this request

SQLMonitoring.java70 行で定義されています。

参照先 org.objectweb.cjdbc.common.log.Trace.debug(), org.objectweb.cjdbc.common.util.Stats.getName(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getStatForRequest(), org.objectweb.cjdbc.common.util.Stats.incrementCount(), org.objectweb.cjdbc.common.log.Trace.isDebugEnabled(), と org.objectweb.cjdbc.common.util.Stats.updateTime().

参照元 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execReadRequest(), org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execReadStoredProcedure(), org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execWriteRequest(), と org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execWriteRequestWithKeys().

00071   {
00072     Stats stat = getStatForRequest(request);
00073     if (stat == null)
00074       return;
00075     stat.incrementCount();
00076     stat.updateTime(time);
00077     if (logger.isDebugEnabled())
00078       logger.debug(time + " " + stat.getName());
00079   }

String org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.monitorRequestRule AbstractRequest  request  )  [private]
 

Check the rule list to check of this request should be monitored or not.

引数:
request the query to look for
戻り値:
the SQL query to monitor or null if monitoring is off for this request

SQLMonitoring.java222 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.AbstractRequest.getSQL(), org.objectweb.cjdbc.common.sql.AbstractRequest.getSqlSkeleton(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoringRule.isMonitoring(), と org.objectweb.cjdbc.controller.monitoring.SQLMonitoringRule.matches().

参照元 org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getStatForRequest().

00223   {
00224     for (int i = 0; i < ruleList.size(); i++)
00225     {
00226       SQLMonitoringRule rule = (SQLMonitoringRule) ruleList.get(i);
00227       String sql = rule.matches(request);
00228       if (sql != null)
00229       { // This rule matches
00230         if (rule.isMonitoring())
00231           return sql;
00232         else
00233           return null;
00234       }
00235     }
00236 
00237     // No rule matched, use the default rule
00238     if (defaultRule)
00239     {
00240       if (request.getSqlSkeleton() == null)
00241         return request.getSQL();
00242       else
00243         return request.getSqlSkeleton();
00244     }
00245     else
00246       return null;
00247   }

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

Reset the stats associated to a request.

引数:
request the request to reset

SQLMonitoring.java116 行で定義されています。

参照先 org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getStatForRequest(), と org.objectweb.cjdbc.common.util.Stats.reset().

00117   {
00118     Stats stat = getStatForRequest(request);
00119     if (stat == null)
00120       return;
00121     stat.reset();
00122   }

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

Defines the default rule

引数:
monitoring true if on, false is off

SQLMonitoring.java200 行で定義されています。

参照元 org.objectweb.cjdbc.controller.xml.DatabasesParser.newSQLMonitoring().

00201   {
00202     this.defaultRule = monitoring;
00203   }


変数

boolean org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.defaultRule [private]
 

SQLMonitoring.java47 行で定義されています。

Trace org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.logger = null [static, private]
 

SQLMonitoring.java49 行で定義されています。

ArrayList org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.ruleList [private]
 

SQLMonitoring.java46 行で定義されています。

Hashtable org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.statList [private]
 

SQLMonitoring.java45 行で定義されています。

参照元 org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.dumpAllStatsInformation(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getAllStatsInformation(), org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.getStatForRequest(), と org.objectweb.cjdbc.controller.monitoring.SQLMonitoring.SQLMonitoring().


このクラスの説明は次のファイルから生成されました:
CJDBCversion1.0rc6に対してWed May 5 18:02:49 2004に生成されました。 doxygen 1.3.6