diff --git a/CHANGES.txt b/CHANGES.txt index defc57fbc7fd..b057a07f2a13 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 78e7265b568a..b79a8fea26e4 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 capacity; + /** Total size of buffer pools, in bytes, including overflow allocation */ public final Gauge size; @@ -52,6 +55,8 @@ public BufferPoolMetrics(String scope, BufferPool bufferPool) 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 35b89a9c8a53..b06e0f31ee97 100644 --- a/src/java/org/apache/cassandra/tools/NodeProbe.java +++ b/src/java/org/apache/cassandra/tools/NodeProbe.java @@ -1404,7 +1404,7 @@ public Object getCacheMetric(String cacheType, String metricName) 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 Object getCacheMetric(String cacheType, String metricName) } } + /** + * 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 getJmxThreadPools(MBeanServerConnection mbeanServerConn) { try @@ -1465,7 +1499,7 @@ public Object getThreadPoolMetric(String pathName, String poolName, String metri 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 1ee6baca6e7d..cf1f894ae865 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 void execute(NodeProbe probe) // 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"));