定时操作和 JDBC 调用
当应用程序服务器中的 JDBC 调用在操作速度上慢于或快于预期时,定时操作会生成已记录的警告。
概述
如果定时操作功能部件已启用,那么会跟踪 JDBC 操作在应用程序服务器中的运行持续时间。在操作所花费的执行时间超过或少于预期时,定时操作功能部件会记录警告。定时操作功能部件将定期地在应用程序服务器日志中创建报告,详细说明执行时间最长的操作。如果运行 server dump 命令,那么定时操作功能部件将生成一个报告,该报告包含此功能部件所跟踪的所有操作的相关信息。您可以使用这些报告中所列出的信息来决定是否有任何项的运行速度慢于或快于预期。
系统会定期向日志中生成一个报告,此报告中包含 10 个最长的 JDBC 定时操作。可在 server.xml 文件中配置此报告的生成频率和是否启用,缺省情况为每天(24 小时)生成一次。
要启用定时操作,请将 timedOperations-1.0 功能部件添加至 server.xml 文件。
可使用 timedOperation 元素禁止将报告生成到日志或更改报告频率(例如,更改为每 12 小时 1 次),如以下示例中所示:
<timedOperation enableReport="false" reportFrequency="12"/>
还可使用 maxNumberTimedOperations 属性来在定时操作总数达到此属性指定的值时记录警告。系统会监视定时操作的数目,知道此数目很有用,因为系统会从堆中为每个定时操作分配内存,如果您发现定时操作数目过大,那么可禁用定时操作功能。可使用以下示例来配置
maxNumberTimedOperations 属性:
<timedOperation enableReport="false" reportFrequency="12" maxNumberTimedOperations="10000"/>
在此示例中,当定时操作数超过 10000 时,日志中会出现如下警告消息:[4/18/13 23:01:37:316 EDT] 0000002c com.ibm.wsspi.timedoperations.TimedOperationService W TRAS0094I:
The total number of timed operations is 10000, which exceeds the configured maximum number of 10000.
You can also find the number of timed operations in the report that is periodically generated to the logs.
If you find that the number of timed operations is excessive, you can disable the timed operations feature.
![[8.5.5.2 或更高版本]](../ng_v8552.gif)
TRAS0095I:定时操作总数已达到配置的最大值 10000。随着新的定时操作的创建,会将最近最少使用的定时操作移除,以维持此级别的所跟踪定时操作总数。
还可使用 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
有关完整的定时操作配置参考,请参阅以下主题中的 timedOperation 元素:在 server.xml 文件中配置元素