You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/08/24 08:13:49 UTC

[groovy] branch master updated: doco: refresh JMX doco

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new cce94ad  doco: refresh JMX doco
cce94ad is described below

commit cce94ad6bef99a4f9bce0843f4411daa5bae5fbd
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Aug 24 18:13:38 2020 +1000

    doco: refresh JMX doco
---
 src/spec/doc/assets/img/catalina.gif               | Bin 6779 -> 0 bytes
 src/spec/doc/assets/img/catalina.png               | Bin 0 -> 21941 bytes
 src/spec/doc/assets/img/jconsole.gif               | Bin 36013 -> 0 bytes
 src/spec/doc/assets/img/jconsole.png               | Bin 0 -> 56764 bytes
 src/spec/doc/assets/img/oc4jpie.gif                | Bin 6889 -> 0 bytes
 src/spec/doc/assets/img/oc4jpie.png                | Bin 0 -> 3664 bytes
 subprojects/groovy-jmx/src/spec/doc/jmx.adoc       | 153 ++++++++++++---------
 .../groovy-jmx/src/spec/test/JmxTest.groovy        |  12 +-
 8 files changed, 98 insertions(+), 67 deletions(-)

diff --git a/src/spec/doc/assets/img/catalina.gif b/src/spec/doc/assets/img/catalina.gif
deleted file mode 100644
index b2f996a..0000000
Binary files a/src/spec/doc/assets/img/catalina.gif and /dev/null differ
diff --git a/src/spec/doc/assets/img/catalina.png b/src/spec/doc/assets/img/catalina.png
new file mode 100644
index 0000000..1590966
Binary files /dev/null and b/src/spec/doc/assets/img/catalina.png differ
diff --git a/src/spec/doc/assets/img/jconsole.gif b/src/spec/doc/assets/img/jconsole.gif
deleted file mode 100644
index eadbc85..0000000
Binary files a/src/spec/doc/assets/img/jconsole.gif and /dev/null differ
diff --git a/src/spec/doc/assets/img/jconsole.png b/src/spec/doc/assets/img/jconsole.png
new file mode 100644
index 0000000..9f71d30
Binary files /dev/null and b/src/spec/doc/assets/img/jconsole.png differ
diff --git a/src/spec/doc/assets/img/oc4jpie.gif b/src/spec/doc/assets/img/oc4jpie.gif
deleted file mode 100644
index 542d7da..0000000
Binary files a/src/spec/doc/assets/img/oc4jpie.gif and /dev/null differ
diff --git a/src/spec/doc/assets/img/oc4jpie.png b/src/spec/doc/assets/img/oc4jpie.png
new file mode 100644
index 0000000..6a803ad
Binary files /dev/null and b/src/spec/doc/assets/img/oc4jpie.png differ
diff --git a/subprojects/groovy-jmx/src/spec/doc/jmx.adoc b/subprojects/groovy-jmx/src/spec/doc/jmx.adoc
index 205cf75..b03ef93 100644
--- a/subprojects/groovy-jmx/src/spec/doc/jmx.adoc
+++ b/subprojects/groovy-jmx/src/spec/doc/jmx.adoc
@@ -24,7 +24,13 @@
 
 == Introduction
 
-Given that Groovy sits directly on top of Java, Groovy can leverage the tremendous amount of work already done for http://www.oracle.com/technetwork/java/javase/tech/javamanagement-140525.html[JMX] with Java. In addition, Groovy provides a `GroovyMBean` class which makes an MBean look like a normal Groovy object. This simplifies Groovy code for interacting with __MBeans__. For example, the following code:
+The https://www.oracle.com/java/technologies/javase/javamanagement.html[Java Management Extensions (JMX)]
+technology provides a standard way of managing resources such as applications, devices, and services on the JDK.
+Each resource to be managed is represented by a __Managed Bean__ (or __MBean__).
+Given that Groovy sits directly on top of Java, Groovy can leverage the tremendous amount of work already
+done for JMX with Java. In addition, Groovy provides a `GroovyMBean` class, in the `groovy-jmx` module,
+which makes an MBean look like a normal Groovy object and simplifies Groovy code for interacting with MBeans.
+For example, the following code:
 
 [source,groovy]
 ----
@@ -61,82 +67,104 @@ When run, you will see something like this:
 
 ----
 OPERATING SYSTEM:
-	architecture = x86
-	name = Windows XP
-	version = 5.1
-	processors = 2
+            	architecture = amd64
+            	name = Windows 10
+            	version = 10.0
+            	processors = 12
 
 RUNTIME:
-	name = 620@LYREBIRD
-	spec name = Java Virtual Machine Specification
-	vendor = Sun Microsystems Inc.
-	spec version = 1.0
-	management spec version = 1.0
+            	name = 724176@QUOKKA
+            	spec name = Java Virtual Machine Specification
+            	vendor = Oracle Corporation
+            	spec version = 11
+            	management spec version = 2.0
 
 CLASS LOADING SYSTEM:
-	isVerbose = false
-	loadedClassCount = 919
-	totalLoadedClassCount = 919
-	unloadedClassCount = 0
+            	isVerbose = false
+            	loadedClassCount = 6962
+            	totalLoadedClassCount = 6969
+            	unloadedClassCount = 0
 
 COMPILATION:
-	totalCompilationTime = 91
+            	totalCompilationTime = 7548
 
 MEMORY:
-HEAP STORAGE:
-	committed = 3108864
-	init = 0
-	max = 66650112
-	used = 1994728
-NON-HEAP STORAGE:
-	committed = 9240576
-	init = 8585216
-	max = 100663296
-	used = 5897880
-
-	name: Code Cache
+            HEAP STORAGE:
+            	committed = 645922816
+            	init = 536870912
+            	max = 8560574464
+            	used = 47808352
+            NON-HEAP STORAGE:
+            	committed = 73859072
+            	init = 7667712
+            	max = -1
+            	used = 70599520
+
+	name: CodeHeap 'non-nmethods'
 		Manager Name: CodeCacheManager
 		mtype = Non-heap memory
 		Usage threshold supported = true
-	name: Eden Space
-		Manager Name: MarkSweepCompact
-		Manager Name: Copy
-		mtype = Heap memory
-		Usage threshold supported = false
-	name: Survivor Space
-		Manager Name: MarkSweepCompact
-		Manager Name: Copy
+	name: Metaspace
+		Manager Name: Metaspace Manager
+		mtype = Non-heap memory
+		Usage threshold supported = true
+	name: CodeHeap 'profiled nmethods'
+		Manager Name: CodeCacheManager
+		mtype = Non-heap memory
+		Usage threshold supported = true
+	name: Compressed Class Space
+		Manager Name: Metaspace Manager
+		mtype = Non-heap memory
+		Usage threshold supported = true
+	name: G1 Eden Space
+		Manager Name: G1 Old Generation
+		Manager Name: G1 Young Generation
 		mtype = Heap memory
 		Usage threshold supported = false
-	name: Tenured Gen
-		Manager Name: MarkSweepCompact
+	name: G1 Old Gen
+		Manager Name: G1 Old Generation
+		Manager Name: G1 Young Generation
 		mtype = Heap memory
 		Usage threshold supported = true
-	name: Perm Gen
-		Manager Name: MarkSweepCompact
+	name: G1 Survivor Space
+		Manager Name: G1 Old Generation
+		Manager Name: G1 Young Generation
+		mtype = Heap memory
+		Usage threshold supported = false
+	name: CodeHeap 'non-profiled nmethods'
+		Manager Name: CodeCacheManager
 		mtype = Non-heap memory
 		Usage threshold supported = true
 
 THREADS:
-	Thread name = Monitor Ctrl-Break
-	Thread name = Signal Dispatcher
-	Thread name = Finalizer
 	Thread name = Reference Handler
-	Thread name = main
+	Thread name = Finalizer
+	Thread name = Signal Dispatcher
+	Thread name = Attach Listener
+	Thread name = Common-Cleaner
+	Thread name = Java2D Disposer
+	Thread name = AWT-Shutdown
+	Thread name = AWT-Windows
+	Thread name = Image Fetcher 0
+	Thread name = AWT-EventQueue-0
+	Thread name = D3D Screen Updater
+	Thread name = DestroyJavaVM
+	Thread name = TimerQueue
+	Thread name = Thread-0
 
 GARBAGE COLLECTION:
-	name = Copy
-		collection count = 60
-		collection time = 141
-		mpool name = Eden Space
-		mpool name = Survivor Space
-	name = MarkSweepCompact
+	name = G1 Young Generation
+		collection count = 6
+		collection time = 69
+		mpool name = G1 Eden Space
+		mpool name = G1 Survivor Space
+		mpool name = G1 Old Gen
+	name = G1 Old Generation
 		collection count = 0
 		collection time = 0
-		mpool name = Eden Space
-		mpool name = Survivor Space
-		mpool name = Tenured Gen
-		mpool name = Perm Gen
+		mpool name = G1 Eden Space
+		mpool name = G1 Survivor Space
+		mpool name = G1 Old Gen
 ----
 
 == Monitoring Tomcat
@@ -151,7 +179,8 @@ set JAVA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port
 
 You can do this in your startup script and may choose any available port, we used 9004.
 
-The following code uses JMX to discover the available MBeans in the running Tomcat, determine which are web modules, extract the processing time for each web module and displays the result in a graph using JFreeChart:
+The following code uses JMX to discover the available MBeans in the running Tomcat, determine which are web modules,
+extract the processing time for each web module and displays the result in a graph using JFreeChart:
 
 [source,groovy]
 ----
@@ -161,18 +190,18 @@ include::{rootProjectDir}/subprojects/groovy-jmx/src/spec/test/JmxTest.groovy[ta
 When run, we will see a trace of progress being made:
 
 ----
-Connected to: Apache Tomcat/6.0.13
+Connected to: Apache Tomcat/9.0.37
 Found 5 web modules. Processing ...
-Catalina:j2eeType=WebModule,name=//localhost/,J2EEApplication=none,J2EEServer=none
-Catalina:j2eeType=WebModule,name=//localhost/host-manager,J2EEApplication=none,J2EEServer=none
 Catalina:j2eeType=WebModule,name=//localhost/docs,J2EEApplication=none,J2EEServer=none
-Catalina:j2eeType=WebModule,name=//localhost/examples,J2EEApplication=none,J2EEServer=none
 Catalina:j2eeType=WebModule,name=//localhost/manager,J2EEApplication=none,J2EEServer=none
+Catalina:j2eeType=WebModule,name=//localhost/,J2EEApplication=none,J2EEServer=none
+Catalina:j2eeType=WebModule,name=//localhost/examples,J2EEApplication=none,J2EEServer=none
+Catalina:j2eeType=WebModule,name=//localhost/host-manager,J2EEApplication=none,J2EEServer=none
 ----
 
 The output will look like this:
 
-image:assets/img/catalina.gif[]
+image:assets/img/catalina.png[]
 
 Note: if you get errors running this script, see the **Troubleshooting** section below.
 
@@ -271,7 +300,7 @@ chart.draw(swing.canvas.graphics, swing.canvas.bounds)
 
 Which looks like:
 
-image:assets/img/oc4jpie.gif[]
+image:assets/img/oc4jpie.png[]
 
 == WebLogic Example
 
@@ -380,9 +409,9 @@ Operations:
   void setBase(int p1)
 ----
 
-You can even attach to the process while it is running with http://docs.oracle.com/javase/1.5.0/docs/guide/management/jconsole.html[jconsole]. It will look something like:
+You can even attach to the process while it is running with https://docs.oracle.com/en/java/javase/14/management/using-jconsole.html[jconsole]. It will look something like:
 
-image:assets/img/jconsole.gif[]
+image:assets/img/jconsole.png[]
 
 We started the Groovy application with the `-Dcom.sun.management.jmxremote` JVM argument.
 
diff --git a/subprojects/groovy-jmx/src/spec/test/JmxTest.groovy b/subprojects/groovy-jmx/src/spec/test/JmxTest.groovy
index 647b8c5..8177faa 100644
--- a/subprojects/groovy-jmx/src/spec/test/JmxTest.groovy
+++ b/subprojects/groovy-jmx/src/spec/test/JmxTest.groovy
@@ -130,10 +130,11 @@ class JmxTest extends CompilableTestSupport {
 
     void testTomcat() {
         shouldCompile '''
-            @Grapes([@Grab('org.jfree:jfreechart:1.0.15'), @Grab('org.codehaus.groovy:groovy-swing:2.1.6')])
+            @Grab('org.jfree:jfreechart:1.5.0')
 
             // tag::tomcat[]
             import groovy.swing.SwingBuilder
+            import groovy.jmx.GroovyMBean
 
             import javax.management.ObjectName
             import javax.management.remote.JMXConnectorFactory as JmxFactory
@@ -168,8 +169,8 @@ class JmxTest extends CompilableTestSupport {
             def chart = ChartFactory.createBarChart(*labels, dataset,
                             Orientation.VERTICAL, *options)
             def swing = new SwingBuilder()
-            def frame = swing.frame(title:'Catalina Module Processing Time', defaultCloseOperation:WC.EXIT_ON_CLOSE) {
-                panel(id:'canvas') { rigidArea(width:600, height:250) }
+            def frame = swing.frame(title:'Catalina Module Processing Time', defaultCloseOperation:WC.DISPOSE_ON_CLOSE) {
+                panel(id:'canvas') { rigidArea(width:800, height:350) }
             }
             frame.pack()
             frame.show()
@@ -209,7 +210,7 @@ class JmxTest extends CompilableTestSupport {
 
     void testSpringClasses() {
         shouldCompile '''
-            @Grab('org.springframework:spring-context:3.2.0.RELEASE')
+            @Grab('org.springframework:spring-context:5.2.8.RELEASE')
             // tag::spring_classes[]
             import org.springframework.jmx.export.annotation.*
 
@@ -260,12 +261,13 @@ class JmxTest extends CompilableTestSupport {
 
     void testSpringUsage() {
         shouldCompile '''
-            @Grab('org.springframework:spring-context:3.2.0.RELEASE')
+            @Grab('org.springframework:spring-context:5.2.8.RELEASE')
             // tag::spring_usage[]
             import org.springframework.context.support.ClassPathXmlApplicationContext
             import java.lang.management.ManagementFactory
             import javax.management.ObjectName
             import javax.management.Attribute
+            import groovy.jmx.GroovyMBean
 
             // get normal bean
             def ctx = new ClassPathXmlApplicationContext("beans.xml")