【问题标题】:Monitoring datasource connection pool on Wildfly9在 Wildfly9 上监控数据源连接池
【发布时间】:2016-06-14 07:06:59
【问题描述】:

我正在从事一个项目,我试图获取我使用 Wildfly-9 放入 /deployment 文件夹的数据源连接池的运行时统计信息。 我搜索了它,发现 /standalone 文件夹中存在名为standalone.xml 文件的配置文件,使用以下代码为我提供了数据源连接池的统计信息:

<datasource jta="true" jndi-name="java:jboss/datasources/DemoDS" pool-name="DemoDS" enabled="true" use-ccm="true" statistics-enabled="true">
    <connection-url>jdbc:mysql://localhost:3306/demo?zeroDateTimeBehavior=convertToNull</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
        <driver>mysql</driver>
        <pool>
            <min-pool-size>1</min-pool-size>
            <max-pool-size>50</max-pool-size>
        </pool>
        <security>
            <user-name>root</user-name>
            <password>root</password>
        </security>
    <validation>
        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
        <background-validation>true</background-validation>
        <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
    </validation>
</datasource>

点击这个网址我得到了这个:

http://localhost:9990/management/subsystem/datasources/data-source/DemoDS/statistics/pool?include-runtime=true

我得到以下 json 字符串: 你得到以下 json 字符串:

{
   "ActiveCount":4,
   "AvailableCount":48,
   "AverageBlockingTime":0,
   "AverageCreationTime":21,
   "AverageGetTime":17,
   "AveragePoolTime":195196,
   "AverageUsageTime":43,
   "BlockingFailureCount":0,
   "CreatedCount":4,
   "DestroyedCount":0,
   "IdleCount":2,
   "InUseCount":2,
   "MaxCreationTime":47,
   "MaxGetTime":47,
   "MaxPoolTime":386185,
   "MaxUsageTime":134,
   "MaxUsedCount":4,
   "MaxWaitCount":0,
   "MaxWaitTime":0,
   "TimedOut":0,
   "TotalBlockingTime":0,
   "TotalCreationTime":87,
   "TotalGetTime":88,
   "TotalPoolTime":780787,
   "TotalUsageTime":217,
   "WaitCount":0,
   "XACommitAverageTime":0,
   "XACommitCount":0,
   "XACommitMaxTime":0,
   "XACommitTotalTime":0,
   "XAEndAverageTime":0,
   "XAEndCount":0,
   "XAEndMaxTime":0,
   "XAEndTotalTime":0,
   "XAForgetAverageTime":0,
   "XAForgetCount":0,
   "XAForgetMaxTime":0,
   "XAForgetTotalTime":0,
   "XAPrepareAverageTime":0,
   "XAPrepareCount":0,
   "XAPrepareMaxTime":0,
   "XAPrepareTotalTime":0,
   "XARecoverAverageTime":0,
   "XARecoverCount":0,
   "XARecoverMaxTime":0,
   "XARecoverTotalTime":0,
   "XARollbackAverageTime":0,
   "XARollbackCount":0,
   "XARollbackMaxTime":0,
   "XARollbackTotalTime":0,
   "XAStartAverageTime":0,
   "XAStartCount":0,
   "XAStartMaxTime":0,
   "XAStartTotalTime":0,
   "statistics-enabled":true
}

由于我有很多数据源文件,我无法放入单独的standalone.xml 文件中。 所以有人知道我将如何获得我放置在 /deployment 文件夹中的数据源连接池的运行时统计信息吗?

【问题讨论】:

  • 我现在没有可尝试的 WildFly 9 实例,但在 WildFly 10 上我有类似 /deployment=mydatasource-ds.xml/subsystem=datasources/xa-data-source=MyDataSource/statistics=pool 的路径

标签: java jboss datasource connection-pooling wildfly-9


【解决方案1】:

来自 Wildfly CLI:

检查是否为数据源启用了统计信息

/subsystem=datasources/data-source=(your datasourcename):read-attribute(name=statistics-enabled)  

启用统计信息:之后需要重启 Wildfly 服务

/subsystem=datasources/data-source=(your datasource):write-attribute(name=statistics-enabled, value=true) 

重启后启动 CLI 并再次运行检查命令。

【讨论】:

  • 设置属性statistics-enabled=true和../data-source=ExampleDS/statistics=pool:read-resource(include-runtime=true)有什么区别?
猜你喜欢
  • 1970-01-01
  • 2012-01-04
  • 1970-01-01
  • 2014-07-25
  • 1970-01-01
  • 1970-01-01
  • 2015-05-31
  • 1970-01-01
相关资源
最近更新 更多