Changes for page JMX Access
Last modified by Michael Hamann on 2023/08/02 11:19
Change comment:
Fix the List cache statistics code by ignoring errors
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -xwiki:XWiki. VincentMassol1 +xwiki:XWiki.MichaelHamann
- ExtensionCode.ExtensionClass[0]
-
- Show installed count
-
... ... @@ -1,0 +1,1 @@ 1 +Yes - Description
-
... ... @@ -132,7 +132,7 @@ 132 132 133 133 Results in: 134 134 135 -{{image reference=jmx.png/}} 135 +{{image reference="jmx.png"/}} 136 136 137 137 = Example 4: Set Log Level for any XWiki category = 138 138 ... ... @@ -155,6 +155,7 @@ 155 155 {{/code}} 156 156 157 157 = Example 5: Getting a full thread-dump = 158 + 158 158 The below code delivers a thread-dump similar to when the QUIT signal is sent on Unix boxes. 159 159 160 160 {{code}} ... ... @@ -203,7 +203,7 @@ 203 203 def names = server.queryNames(query, null) 204 204 names.each { 205 205 println "== Cache: ${it.getKeyProperty('name')} ==" 206 - def mbean = new GroovyMBean(server, it) 207 + def mbean = new GroovyMBean(server, it, true) 207 207 for(attr in mbean.listAttributeNames()) { 208 208 println "* ${attr}: ${mbean.getProperty(attr)}" 209 209 } ... ... @@ -210,3 +210,24 @@ 210 210 } 211 211 {{/groovy}} 212 212 {{/code}} 214 + 215 += Example 7: Switch statistics collection states (enabled/disabled) on a cache = 216 + 217 +Example to switch the current state of statistics collection for the page cache ("xwiki.store.pagecache(local)"): 218 + 219 +{{code}} 220 +{{groovy}} 221 +import java.lang.management.ManagementFactory; 222 +import javax.management.MBeanServer; 223 +import javax.management.ObjectName; 224 +import javax.management.Attribute; 225 + 226 +MBeanServer server = ManagementFactory.getPlatformMBeanServer(); 227 +def objectName = new ObjectName('org.xwiki.infinispan:type=Cache,name="xwiki.store.pagecache(local)",manager="xwiki",component=Statistics') 228 +def statsState = server.getAttribute(objectName,'statisticsEnabled') 229 +println "Statistics were ${statsState ? 'enabled' : 'disabled'}"; 230 +def enableStats = new Attribute("statisticsEnabled", !statsState); 231 +server.setAttribute(objectName,enableStats); 232 +println "Statistics are now ${server.getAttribute(objectName,'statisticsEnabled') ? 'enabled' : 'disabled'}"; 233 +{{/groovy}} 234 +{{/code}}