This is an automated email from the ASF dual-hosted git repository.
brandonwilliams pushed a commit to branch cassandra-4.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-4.0 by this push:
new 54528bff20 Report network cache info in nodetool
54528bff20 is described below
commit 54528bff2027d6c8cab845a83f2c03ad9441edbd
Author: ningzi.zhan <[email protected]>
AuthorDate: Thu May 18 13:51:14 2023 -0700
Report network cache info in nodetool
Patch by Ningzi Zhan; reviewed by brandonwilliams and smiklosovic for
CASSANDRA-18400
---
CHANGES.txt | 1 +
.../cassandra/metrics/BufferPoolMetrics.java | 5 +++
src/java/org/apache/cassandra/tools/NodeProbe.java | 38 ++++++++++++++++++++--
.../org/apache/cassandra/tools/nodetool/Info.java | 16 +++++++++
4 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index defc57fbc7..b057a07f2a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
4.0.10
+ * Report network cache info in nodetool (CASSANDRa-18400)
* Partial compaction can resurrect deleted data (CASSANDRA-18507)
* Allow internal address to change with reconnecting snitches
(CASSANDRA-16718)
* Fix quoting in toCqlString methods of UDTs and aggregates (CASSANDRA-17918)
diff --git a/src/java/org/apache/cassandra/metrics/BufferPoolMetrics.java
b/src/java/org/apache/cassandra/metrics/BufferPoolMetrics.java
index 78e7265b56..b79a8fea26 100644
--- a/src/java/org/apache/cassandra/metrics/BufferPoolMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/BufferPoolMetrics.java
@@ -31,6 +31,9 @@ public class BufferPoolMetrics
/** Total number of misses */
public final Meter misses;
+ /** Total threshold for a certain type of buffer pool*/
+ public final Gauge<Long> capacity;
+
/** Total size of buffer pools, in bytes, including overflow allocation */
public final Gauge<Long> size;
@@ -52,6 +55,8 @@ public class BufferPoolMetrics
misses = Metrics.meter(factory.createMetricName("Misses"));
+ capacity = Metrics.register(factory.createMetricName("Capacity"),
bufferPool::memoryUsageThreshold);
+
overflowSize =
Metrics.register(factory.createMetricName("OverflowSize"),
bufferPool::overflowMemoryInBytes);
usedSize = Metrics.register(factory.createMetricName("UsedSize"),
bufferPool::usedSizeInBytes);
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java
b/src/java/org/apache/cassandra/tools/NodeProbe.java
index 35b89a9c8a..b06e0f31ee 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -1404,7 +1404,7 @@ public class NodeProbe implements AutoCloseable
new
ObjectName("org.apache.cassandra.metrics:type=Cache,scope=" + cacheType +
",name=MissLatency"),
CassandraMetricsRegistry.JmxTimerMBean.class).getDurationUnit();
default:
- throw new RuntimeException("Unknown cache metric name.");
+ throw new RuntimeException("Unknown Cache metric name " +
metricName);
}
}
@@ -1414,6 +1414,40 @@ public class NodeProbe implements AutoCloseable
}
}
+ /**
+ * Retrieve buffer pool metrics based on the buffer pool type
+ * @param poolType networking chunk-cache
+ * @param metricName UsedSize Size
+ * @return
+ */
+ public Object getBufferPoolMetric(String poolType, String metricName)
+ {
+ try
+ {
+ switch (metricName)
+ {
+ case "UsedSize":
+ case "OverflowSize":
+ case "Capacity":
+ case "Size":
+ return JMX.newMBeanProxy(mbeanServerConn,
+ new
ObjectName("org.apache.cassandra.metrics:type=BufferPool,scope=" + poolType +
",name=" + metricName),
+
CassandraMetricsRegistry.JmxGaugeMBean.class).getValue();
+ case "Hits":
+ case "Misses":
+ return JMX.newMBeanProxy(mbeanServerConn,
+ new
ObjectName("org.apache.cassandra.metrics:type=BufferPool,scope=" + poolType +
",name=" + metricName),
+ CassandraMetricsRegistry.JmxMeterMBean.class).getCount();
+ default:
+ throw new RuntimeException("Unknown BufferPool metric name
" + metricName);
+ }
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
private static Multimap<String, String>
getJmxThreadPools(MBeanServerConnection mbeanServerConn)
{
try
@@ -1465,7 +1499,7 @@ public class NodeProbe implements AutoCloseable
case ThreadPoolMetrics.CURRENTLY_BLOCKED_TASKS:
return JMX.newMBeanProxy(mbeanServerConn, oName,
JmxReporter.JmxCounterMBean.class).getCount();
default:
- throw new AssertionError("Unknown metric name " +
metricName);
+ throw new AssertionError("Unknown ThreadPools metric name "
+ metricName);
}
}
catch (Exception e)
diff --git a/src/java/org/apache/cassandra/tools/nodetool/Info.java
b/src/java/org/apache/cassandra/tools/nodetool/Info.java
index 1ee6baca6e..cf1f894ae8 100644
--- a/src/java/org/apache/cassandra/tools/nodetool/Info.java
+++ b/src/java/org/apache/cassandra/tools/nodetool/Info.java
@@ -140,6 +140,22 @@ public class Info extends NodeToolCmd
// Chunk cache is not on.
}
+ // network Cache: capacity, size
+ try
+ {
+ out.printf("%-23s: size %s, overflow size: %s, capacity %s%n",
"Network Cache",
+ FileUtils.stringifyFileSize((long)
probe.getBufferPoolMetric("networking", "Size")),
+ FileUtils.stringifyFileSize((long)
probe.getBufferPoolMetric("networking", "OverflowSize")),
+ FileUtils.stringifyFileSize((long)
probe.getBufferPoolMetric("networking", "Capacity")));
+ }
+ catch (RuntimeException e)
+ {
+ if (!(e.getCause() instanceof InstanceNotFoundException))
+ throw e;
+
+ // network cache is not on.
+ }
+
// Global table stats
out.printf("%-23s: %s%%%n", "Percent Repaired",
probe.getColumnFamilyMetric(null, null, "PercentRepaired"));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]