-
Couldn't load subscription status.
- Fork 161
Fixes in monitoring, enable monitoring in Embedded GlassFish #25752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fixes in monitoring, enable monitoring in Embedded GlassFish #25752
Conversation
Requires running with flashlight-agent on command line with -javaagent:flashlight-agent.jar When started with command "enable-monitoring --mbean true", metric will be available via JMX beans
Needed for monitoring, at least in Embedded GlassFish. Otherwise: java.lang.reflect.InaccessibleObjectException: Unable to make public java.util.Enumeration jdk.internal.loader.BuiltinClassLoader.findResources(java.lang.String) throws java.io.IOException accessible: module java.base does not "exports jdk.internal.loader" to unnamed module @1de0aca6 at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315) at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:203) at java.base/java.lang.reflect.Method.setAccessible(Method.java:197) at com.sun.enterprise.module.single.ManifestProxy.<init>(ManifestProxy.java:71) at com.sun.enterprise.module.single.ProxyModuleDefinition.generate(ProxyModuleDefinition.java:146) at com.sun.enterprise.module.single.ProxyModuleDefinition.getManifest(ProxyModuleDefinition.java:134) at org.glassfish.admin.monitor.MonitoringBootstrap.addProvider(MonitoringBootstrap.java:298)
f7871b9 to
6c3eff8
Compare
d4bdf73 to
28dd44c
Compare
Disable test for Embedded Web - it doesn't support AMX because it doesn't include glassfish-mbeanserver artifact.
28dd44c to
0a14238
Compare
- do not unregister probes when deleting listener, unless it's the last listener - count busy threads in the monitor and pass info to stats (maybe not necessary) - catch out of bounds exception in probes, which sometimes happens, probably because of a probe is removed concurrently from the array while iterating through the collection - global stats updates with the setCurrentThreadCountEvent event
| } | ||
| } | ||
| } catch (IndexOutOfBoundsException e) { | ||
| logger.log(FINE, "", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? Maybe it would be better to clone the list and then use just foreach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's not nice. But I suspect this situation happens when the list is modified in parallel. And when a probe is removed, we don't want to execute it, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, actually, I didn't realize that a probe can be removed also from the middle. So you are right. I'll do as you suggest. It doesn't matter if the probe is execute a few moments after it was removed.
| <plugins> | ||
| <plugin> | ||
| <groupId>org.codehaus.gmaven</groupId> | ||
| <artifactId>groovy-maven-plugin</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer using java and exec plugin; not sure if it is doable.
The groovy is not so well readable for us and we tend to do evil things: catching exceptions without processing them, closing jars just when their processing doesn't throw exceptions instead of try-with ...
Also adds tests for it. Also adds support for a system property glassfish.remote, to run tests against a remote server instead of setting up a local (managed) one and stopping it after tests. This helps in debugging test scenarios.
Ensures that the reported current thread count and busy thread count is exactly the number of threads reported by the pool. Even if monitoring is started while thread pool is actively processing requests.
A few improvements in Embedded GlassFish to enable monitoring and access it via JMX (it was completely broken before):
probe-provider-class-namesMANIFEST elements from dependencies, using gmaven plugin script at build time. It references all probes that should be activatedEmbedded GlassFish requires running with flashlight-agent on command line with -javaagent:flashlight-agent.jar on newer Java versions as it doesn't contain the agent. Dynamic loading of agent is not a good practice with newer Java versions anyway.
When started with command "enable-monitoring --mbean true", metric will be available via JMX beans:
Example to start Embedded GlassFish with thread pool and http service metrics:
Or, alternatively, using the following properties in
glassfish.propertiesin the current directory:And command:
Then in VisualVM (with MBeans extension), in the
amxnode:If you don't see the
amxnode, you need to execute thebootAMXoperation from VisualVM first (the added test demonstrates how to do that in code):