定时操作和 JDBC 调用
当应用程序服务器中的 JDBC 调用在操作速度上慢于或快于预期时,定时操作会生成已记录的警告。
概述
如果定时操作功能部件已启用,那么会跟踪 JDBC 操作在应用程序服务器中的运行持续时间。在操作所花费的执行时间超过或少于预期时,定时操作功能部件会记录警告。定时操作功能部件将定期地在应用程序服务器日志中创建报告,详细说明执行时间最长的操作。如果运行 server dump 命令,那么定时操作功能部件将生成一个报告,该报告包含此功能部件所跟踪的所有操作的相关信息。您可以使用这些报告中所列出的信息来决定是否有任何项的运行速度慢于或快于预期。
系统会定期向日志中生成一个报告,此报告中包含 10 个最长的 JDBC 定时操作。可在 server.xml 文件中配置此报告的生成频率和是否启用,缺省情况为每天(24 小时)生成一次。
要启用定时操作,请将 timedOperations-1.0 功能部件添加至 server.xml 文件。
可使用 timedOperation 元素禁止将报告生成到日志或更改报告频率(例如,更改为每 12 小时 1 次),如以下示例中所示:
<timedOperation enableReport="false" reportFrequency="12" />
服务器会自动将跟踪的定时操作数限制为 <maxNumberTimedOperations> 属性所指定的值。定时操作总数达到指定的最大值时记录警告。
<timedOperation enableReport="false" reportFrequency="12" maxNumberTimedOperations="10000"/>
为限制跟踪的定时操作数,在需要跟踪新的定时操作时,会删除最近最少使用的定时操作记录。当跟踪的定时操作数达到指定的最大值时,将显示一条警告,如下所示:TRAS0095I: The total number of timed operations has reached the configured maximum of 10000. As new timed operations are created the least recently used timed operations will be removed to maintain the total number of tracked timed operations at this level.
还可使用 server dump 命令以在 messages.log 文件中获取所有定时操作的完整报告,这些操作按类型分组,每组内按实际的平均持续时间进行排序。
以下示例显示了一条已记录的样本消息:
[3/14/13 14:01:25:960 CDT] 00000025 TimedOperatio W TRAS0080W: Operation websphere.datasource.execute:
jdbc/exampleDS:insert into cities values ('myHomeCity', 106769, 'myHomeCountry') took 1.541 ms to complete,
which was longer than the expected duration of 0.213 ms based on past observations.
以下示例显示了日志中自动生成的样本报告:
[12/13/12 7:42:29:509 CST] 0000001d com.ibm.wsspi.timedoperations.TimedOperationService I TRAS0092I:
The following operations took the longest time to run since the last report has been generated:
Operation websphere.datasource.execute:jdbc/exampleDS:insert into cities values ('myHomeCity',
106769, 'myHomeCounty') took 194ms to complete
Operation websphere.datasource.execute:jdbc/exampleDS:select county from cities where name=
'myHomeCity' took 187ms to complete
Operation websphere.datasource.execute:jdbc/exampleDS:drop table cities took 182ms to
complete\Operation websphere.datasource.execute:jdbc/exampleDS:insert into cities values
('myHomeCity', 106769, 'myHomeCounty') took 151ms to complete
有关完整的定时操作配置参考,请参阅定时操作。