第 4 章 启用并配置 Data Grid 统计和 JMX 监控
网格可以提供缓存管理器和缓存统计信息,以及导出 JMX MBeans。
4.1. 在嵌入式缓存中启用统计信息
配置 Data Grid 以导出缓存管理器和嵌入式缓存的统计信息。
流程
- 打开 Data Grid 配置以进行编辑。
-
添加
statistics="true"
属性或.statistics (true)
方法。 - 保存并关闭您的 Data Grid 配置。
嵌入式缓存统计
XML
<infinispan> <cache-container statistics="true"> <distributed-cache statistics="true"/> <replicated-cache statistics="true"/> </cache-container> </infinispan>
GlobalConfigurationBuilder
GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder().cacheContainer().statistics(true); DefaultCacheManager cacheManager = new DefaultCacheManager(global.build()); Configuration builder = new ConfigurationBuilder(); builder.statistics().enable();