-
Notifications
You must be signed in to change notification settings - Fork 3.8k
CASSANDRA-21037 4.1 backport of CASSANDRA-19022 - nodetool gcstats on direct memory #4498
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: cassandra-4.1
Are you sure you want to change the base?
Conversation
|
@smiklosovic I don't see a PR for 5.0, only 4.1 and 4.0 |
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.
Pull request overview
This PR backports CASSANDRA-19022 to the 4.1 branch, adding support for tracking direct memory in nodetool gcstats across different Java versions.
Key changes:
- Separates handling of Java 8's
totalCapacity(long) and Java 11'sTOTAL_CAPACITY(AtomicLong) fields - Refactors the static initialization to attempt loading both field variants
- Introduces helper methods
getField()andgetFieldValue()for cleaner field access
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private static long getAllocatedDirectMemory() | ||
| { | ||
| if (BITS_TOTAL_CAPACITY == null) return -1; | ||
| long fieldValue = getFieldValue(BITS_TOTAL_CAPACITY_JAVA_8, true); |
Copilot
AI
Nov 28, 2025
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.
The isAtomicLong parameter should be false for the Java 8 field. In Java 8, totalCapacity is a regular long field, not an AtomicLong. Only in Java 11 was it changed to TOTAL_CAPACITY as an AtomicLong.
This will cause a ClassCastException when running on Java 8, as the code will attempt to cast a Long to AtomicLong.
Suggested fix:
long fieldValue = getFieldValue(BITS_TOTAL_CAPACITY_JAVA_8, false);| long fieldValue = getFieldValue(BITS_TOTAL_CAPACITY_JAVA_8, true); | |
| long fieldValue = getFieldValue(BITS_TOTAL_CAPACITY_JAVA_8, false); |
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.
bad bot! This is not true, both of them are AtomicLong, it is just in Java 8 and 11 they differ on names.
Thanks for sending a pull request! Here are some tips if you're new here:
Commit messages should follow the following format:
The Cassandra Jira