From 9baae7b80767b077403a75cd1c1e2589ae38b0ba Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Fri, 13 Jun 2014 11:35:07 -0500 Subject: [PATCH] fix merge --- .../org/apache/cassandra/db/Keyspace.java | 2 - .../cassandra/metrics/KeyspaceMetrics.java | 94 ++++++++++++++++--- 2 files changed, 80 insertions(+), 16 deletions(-) diff --git a/src/java/org/apache/cassandra/db/Keyspace.java b/src/java/org/apache/cassandra/db/Keyspace.java index 8762643940..54054c5e06 100644 --- a/src/java/org/apache/cassandra/db/Keyspace.java +++ b/src/java/org/apache/cassandra/db/Keyspace.java @@ -64,8 +64,6 @@ public class Keyspace public final KeyspaceMetrics metric; - public final KeyspaceMetrics metric; - // It is possible to call Keyspace.open without a running daemon, so it makes sense to ensure // proper directories here as well as in CassandraDaemon. static diff --git a/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java b/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java index 4a0980f384..7ef8a752ea 100644 --- a/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java +++ b/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java @@ -32,16 +32,24 @@ import org.apache.cassandra.db.Keyspace; */ public class KeyspaceMetrics { - /** Total amount of data stored in the memtable, including column related overhead. */ - public final Gauge memtableDataSize; - /** Total amount of data stored in the memtables (2i and pending flush memtables included). */ - public final Gauge allMemtablesDataSize; + /** Total amount of live data stored in the memtable, excluding any data structure overhead */ + public final Gauge memtableLiveDataSize; + /** Total amount of data stored in the memtable that resides on-heap, including column related overhead and overwritten rows. */ + public final Gauge memtableOnHeapDataSize; + /** Total amount of data stored in the memtable that resides off-heap, including column related overhead and overwritten rows. */ + public final Gauge memtableOffHeapDataSize; + /** Total amount of live data stored in the memtables (2i and pending flush memtables included) that resides off-heap, excluding any data structure overhead */ + public final Gauge allMemtablesLiveDataSize; + /** Total amount of data stored in the memtables (2i and pending flush memtables included) that resides on-heap. */ + public final Gauge allMemtablesOnHeapDataSize; + /** Total amount of data stored in the memtables (2i and pending flush memtables included) that resides off-heap. */ + public final Gauge allMemtablesOffHeapDataSize; /** Total number of columns present in the memtable. */ public final Gauge memtableColumnsCount; /** Number of times flush has resulted in the memtable being switched out. */ public final Gauge memtableSwitchCount; /** Estimated number of tasks pending for this column family */ - public final Gauge pendingTasks; + public final Gauge pendingFlushes; /** Estimate of number of pending compactios for this CF */ public final Gauge pendingCompactions; /** Disk space used by SSTables belonging to this CF */ @@ -74,26 +82,74 @@ public class KeyspaceMetrics return total; } }); - memtableDataSize = Metrics.newGauge(factory.createMetricName("MemtableDataSize"), new Gauge() + memtableLiveDataSize = Metrics.newGauge(factory.createMetricName("MemtableLiveDataSize"), new Gauge() { public Long value() { long total = 0; for (ColumnFamilyStore cf : ks.getColumnFamilyStores()) { - total += cf.metric.memtableDataSize.value(); + total += cf.metric.memtableLiveDataSize.value(); } return total; } }); - allMemtablesDataSize = Metrics.newGauge(factory.createMetricName("AllMemtablesDataSize"), new Gauge() + memtableOnHeapDataSize = Metrics.newGauge(factory.createMetricName("MemtableOnHeapDataSize"), new Gauge() { public Long value() { long total = 0; for (ColumnFamilyStore cf : ks.getColumnFamilyStores()) { - total += cf.metric.allMemtablesDataSize.value(); + total += cf.metric.memtableOnHeapSize.value(); + } + return total; + } + }); + memtableOffHeapDataSize = Metrics.newGauge(factory.createMetricName("MemtableiOffHeapDataSize"), new Gauge() + { + public Long value() + { + long total = 0; + for (ColumnFamilyStore cf : ks.getColumnFamilyStores()) + { + total += cf.metric.memtableOffHeapSize.value(); + } + return total; + } + }); + allMemtablesLiveDataSize = Metrics.newGauge(factory.createMetricName("AllMemtablesLiveDataSize"), new Gauge() + { + public Long value() + { + long total = 0; + for (ColumnFamilyStore cf : ks.getColumnFamilyStores()) + { + total += cf.metric.allMemtablesLiveDataSize.value(); + } + return total; + } + }); + allMemtablesOnHeapDataSize = Metrics.newGauge(factory.createMetricName("AllMemtablesOnHeapDataSize"), new Gauge() + { + public Long value() + { + long total = 0; + for (ColumnFamilyStore cf : ks.getColumnFamilyStores()) + { + total += cf.metric.allMemtablesOnHeapSize.value(); + } + return total; + } + }); + allMemtablesOffHeapDataSize = Metrics.newGauge(factory.createMetricName("AllMemtablesOffHeapDataSize"), new Gauge() + { + public Long value() + { + long total = 0; + for (ColumnFamilyStore cf : ks.getColumnFamilyStores()) + { + total += cf.metric.allMemtablesOffHeapSize.value(); } return total; } @@ -120,11 +176,16 @@ public class KeyspaceMetrics return sum; } }); - pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge() + pendingFlushes = Metrics.newGauge(factory.createMetricName("PendingFlushes"), new Gauge() { public Integer value() { - return Keyspace.switchLock.getQueueLength(); + int sum = 0; + for (ColumnFamilyStore cf : ks.getColumnFamilyStores()) + { + sum += cf.metric.pendingFlushes.count(); + } + return sum; } }); liveDiskSpaceUsed = Metrics.newGauge(factory.createMetricName("LiveDiskSpaceUsed"), new Gauge() @@ -168,10 +229,15 @@ public class KeyspaceMetrics */ public void release() { - Metrics.defaultRegistry().removeMetric(factory.createMetricName("AllMemtablesDataSize")); - Metrics.defaultRegistry().removeMetric(factory.createMetricName("MemtableDataSize")); + Metrics.defaultRegistry().removeMetric(factory.createMetricName("AllMemtablesLiveDateSize")); + Metrics.defaultRegistry().removeMetric(factory.createMetricName("AllMemtablesOnHeapDataSize")); + Metrics.defaultRegistry().removeMetric(factory.createMetricName("AllMemtablesOffHeapDataSize")); + Metrics.defaultRegistry().removeMetric(factory.createMetricName("MemtableLiveDataSize")); + Metrics.defaultRegistry().removeMetric(factory.createMetricName("MemtableOnHeapDataSize")); + Metrics.defaultRegistry().removeMetric(factory.createMetricName("MemtableOffHeapDataSize")); Metrics.defaultRegistry().removeMetric(factory.createMetricName("MemtableSwitchCount")); - Metrics.defaultRegistry().removeMetric(factory.createMetricName("PendingTasks")); + Metrics.defaultRegistry().removeMetric(factory.createMetricName("PendingFlushes")); + Metrics.defaultRegistry().removeMetric(factory.createMetricName("PendingCompactions")); Metrics.defaultRegistry().removeMetric(factory.createMetricName("LiveDiskSpaceUsed")); Metrics.defaultRegistry().removeMetric(factory.createMetricName("TotalDiskSpaceUsed")); Metrics.defaultRegistry().removeMetric(factory.createMetricName("BloomFilterDiskSpaceUsed"));