JvmMonitor: Handle more generation and collector scenarios.#12469
JvmMonitor: Handle more generation and collector scenarios.#12469gianm merged 5 commits intoapache:masterfrom
Conversation
ZGC on Java 11 only has a generation 1 (there is no 0). This causes a NullPointerException when trying to extract the spacesCount for generation 0. In addition, ZGC on Java 15 has a collector number 2 but no spaces in generation 2, which breaks the assumption that collectors always have same-numbered spaces. This patch adjusts things to be more robust, enabling the JvmMonitor to work properly for ZGC on both Java 11 and 15.
|
I notice that we're using the JStatData APIs provided in the The JDK itself provides public management API to allow us to access these counters.
I think we can use these APIs to replace the old one so that we:
BTW, I'm not saying we need to do this in this PR. |
|
@FrankChen021 That sounds like it would be an excellent enhancement. I'm not sure why the current code uses JStatData instead of the MXBeans. IMO we could merge this patch now, and then switch to MXBeans when someone has the opportunity to write & test a new version of the JvmMonitor. |
ZGC on Java 11 only has a generation 1 (there is no 0). This causes
a NullPointerException when trying to extract the spacesCount for
generation 0. In addition, ZGC on Java 15 has a collector number 2
but no spaces in generation 2, which breaks the assumption that
collectors always have same-numbered spaces.
This patch adjusts things to be more robust, enabling the JvmMonitor
to work properly for ZGC on both Java 11 and 15.