cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject [1/2] git commit: Expose droppable tombstone ratio stats over JMX patch by meriksson reviewed by dbrosius for CASSANDRA-5159
Date Thu, 17 Jan 2013 05:37:34 GMT
Expose droppable tombstone ratio stats over JMX
patch by meriksson reviewed by dbrosius for CASSANDRA-5159


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/205a9939
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/205a9939
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/205a9939

Branch: refs/heads/trunk
Commit: 205a9939c19b5fe10b59589c41c37f04543c8ad8
Parents: 4024605
Author: Dave Brosius <dbrosius@apache.org>
Authored: Thu Jan 17 00:32:09 2013 -0500
Committer: Dave Brosius <dbrosius@apache.org>
Committed: Thu Jan 17 00:32:09 2013 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |    2 +
 .../org/apache/cassandra/db/ColumnFamilyStore.java |    5 ++++
 .../cassandra/db/ColumnFamilyStoreMBean.java       |    6 +++++
 src/java/org/apache/cassandra/db/DataTracker.java  |   18 +++++++++++++++
 .../cassandra/io/sstable/SSTableMetadata.java      |   12 +++++++++-
 .../apache/cassandra/io/sstable/SSTableReader.java |    5 ++++
 6 files changed, 47 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/205a9939/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d71fd28..f684d6b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -50,6 +50,8 @@ Merged from 1.1:
  * better handling for amid compaction failure (CASSANDRA-5137)
  * calculate pending ranges asynchronously (CASSANDRA-5135)
  * convert default marshallers list to map for better readability (CASSANDRA-5109)
+ * Expose droppable tombstone ratio stats over JMX (CASSANDRA-5159)
+ 
 
 
 1.2.0

http://git-wip-us.apache.org/repos/asf/cassandra/blob/205a9939/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 7072921..cb12792 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -2043,4 +2043,9 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         markCompacted(truncatedSSTables, OperationType.UNKNOWN);
         return ReplayPosition.getReplayPosition(truncatedSSTables);
     }
+
+    public double getDroppableTombstoneRatio()
+    {
+        return getDataTracker().getDroppableTombstoneRatio();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/205a9939/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java b/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
index 0a6b077..554c204 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
@@ -333,4 +333,10 @@ public interface ColumnFamilyStoreMBean
      *         array index corresponds to level(int[0] is for level 0, ...).
      */
     public int[] getSSTableCountPerLevel();
+
+    /**
+     * Get the ratio of droppable tombstones to real columns (and non-droppable tombstones)
+     * @return ratio
+     */
+    public double getDroppableTombstoneRatio();
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/205a9939/src/java/org/apache/cassandra/db/DataTracker.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DataTracker.java b/src/java/org/apache/cassandra/db/DataTracker.java
index 7e8887f..749b64e 100644
--- a/src/java/org/apache/cassandra/db/DataTracker.java
+++ b/src/java/org/apache/cassandra/db/DataTracker.java
@@ -389,6 +389,24 @@ public class DataTracker
         return count > 0 ? (int) (sum / count) : 0;
     }
 
+    public double getDroppableTombstoneRatio()
+    {
+        double allDroppable = 0;
+        long allColumns = 0;
+        int localTime = (int)(System.currentTimeMillis()/1000);
+
+        for (SSTableReader sstable : getSSTables())
+        {
+            allDroppable += sstable.getDroppableTombstonesBefore(localTime - sstable.metadata.getGcGraceSeconds());
+            allColumns += sstable.getEstimatedColumnCount().mean() * sstable.getEstimatedColumnCount().count();
+        }
+        if (allColumns > 0)
+        {
+            return allDroppable / allColumns;
+        }
+        return 0;
+    }
+
     public void notifySSTablesChanged(Iterable<SSTableReader> removed, Iterable<SSTableReader>
added, OperationType compactionType)
     {
         for (INotificationConsumer subscriber : subscribers)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/205a9939/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java b/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java
index e53fdf9..8bd9e35 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java
@@ -121,12 +121,22 @@ public class SSTableMetadata
         long estimatedColumnCount = this.estimatedColumnCount.mean() * this.estimatedColumnCount.count();
         if (estimatedColumnCount > 0)
         {
-            double droppable = estimatedTombstoneDropTime.sum(gcBefore);
+            double droppable = getDroppableTombstonesBefore(gcBefore);
             return droppable / estimatedColumnCount;
         }
         return 0.0f;
     }
 
+    /**
+     * Get the amount of droppable tombstones
+     * @param gcBefore the gc time
+     * @return amount of droppable tombstones
+     */
+    public double getDroppableTombstonesBefore(int gcBefore)
+    {
+        return estimatedTombstoneDropTime.sum(gcBefore);
+    }
+
     public static class Collector
     {
         protected EstimatedHistogram estimatedRowSize = defaultRowSizeHistogram();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/205a9939/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
index 42b4ae6..d0ef5d8 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
@@ -1086,6 +1086,11 @@ public class SSTableReader extends SSTable
         return sstableMetadata.getEstimatedDroppableTombstoneRatio(gcBefore);
     }
 
+    public double getDroppableTombstonesBefore(int gcBefore)
+    {
+        return sstableMetadata.getDroppableTombstonesBefore(gcBefore);
+    }
+
     public double getCompressionRatio()
     {
         return sstableMetadata.compressionRatio;


Mime
View raw message