Skip to content

CASSANDRA-14366: Add prepared statement cache stats to nodetool info - #4969

Open
arvindKandpal-ksolves wants to merge 6 commits into
apache:trunkfrom
arvindKandpal-ksolves:CASSANDRA-14366
Open

CASSANDRA-14366: Add prepared statement cache stats to nodetool info#4969
arvindKandpal-ksolves wants to merge 6 commits into
apache:trunkfrom
arvindKandpal-ksolves:CASSANDRA-14366

Conversation

@arvindKandpal-ksolves

Copy link
Copy Markdown
Contributor

Summary of Changes

This PR adds prepared statement cache statistics to the nodetool info command output, bringing it into alignment with other cache metrics (such as Key Cache, Row Cache, Counter Cache, and Chunk Cache).

Key Implementation Details

  1. CQLMetrics.java: Added preparedStatementsCacheCapacity as a new JMX Gauge (PreparedStatementsCacheCapacity) to expose the configured cache memory limit (QueryProcessor.PREPARED_STATEMENT_CACHE_SIZE_BYTES).
  2. NodeProbe.java: Added getCQLMetric(String metricName) helper method to fetch CQL metrics via JMX (JmxGaugeMBean for gauges, JmxCounterMBean for counters).
  3. Info.java: Updated nodetool info output to display prepared statement cache stats (entries, current size, capacity, executions, and evictions).
  4. InternalNodeProbe.java: Added @Override for getCQLMetric() throwing UnsupportedOperationException to maintain consistency with existing mock methods in distributed test framework.
  5. InfoTest.java: Added a unit test validating that nodetool info correctly includes and formats the Prepared Stmt Cache line.

Assisted-by: Claude Sonnet 4.6 (1M context) noreply@anthropic.com

patch by Arvind Kandpal; reviewed by TBD for CASSANDRA-14366

Comment thread src/java/org/apache/cassandra/tools/NodeProbe.java
@arvindKandpal-ksolves

Copy link
Copy Markdown
Contributor Author

Hi @smiklosovic , I have refactored the method to fetch the metrics dynamically and removed the hardcoded names. Please take a look.

try
{
out.printf("%-23s: entries %d, size %s, capacity %s, %d executions, %d evictions%n",
"Prepared Stmt Cache",

@smiklosovic smiklosovic Jul 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arvindKandpal-ksolves please change "Stmt" to "Statement" (use full form, not the shortcut). Apply across the whole patch.

Also please align these arguments under the first one of printf.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated these.
But not sure with the align , as my previous alignment look same as other part of code , but I have updated , Please review once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants