cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject git commit: Add SSTable count per level to cfstats patch by yukim; reviewed by jbellis for CASSANDRA-4537
Date Tue, 11 Sep 2012 22:23:33 GMT
Updated Branches:
  refs/heads/trunk c5df20832 -> c64d975cd


Add SSTable count per level to cfstats patch by yukim; reviewed by jbellis for CASSANDRA-4537


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

Branch: refs/heads/trunk
Commit: c64d975cdf9eebddb04801573035a7272f779fed
Parents: c5df208
Author: Yuki Morishita <yukim@apache.org>
Authored: Tue Sep 11 17:22:49 2012 -0500
Committer: Yuki Morishita <yukim@apache.org>
Committed: Tue Sep 11 17:22:49 2012 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../org/apache/cassandra/db/ColumnFamilyStore.java |    7 +++++
 .../cassandra/db/ColumnFamilyStoreMBean.java       |    6 ++++
 .../db/compaction/LeveledCompactionStrategy.java   |    5 +++
 .../cassandra/db/compaction/LeveledManifest.java   |    8 +++++
 src/java/org/apache/cassandra/tools/NodeCmd.java   |   21 +++++++++++++++
 6 files changed, 48 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c64d975c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 8d373cf..630ae18 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -60,6 +60,7 @@
  * Accept all thrift update on CQL3 cf but don't expose their metadata (CASSANDRA-4377)
  * Replace Throttle with Guava's RateLimiter for HintedHandOff (CASSANDRA-4541)
  * fix counter add/get using CQL2 and CQL3 in stress tool (CASSANDRA-4633)
+ * Add sstable count per level to cfstats (CASSANDRA-4537)
 
 
 1.1.6

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c64d975c/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 d292a63..b539228 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -2000,6 +2000,13 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
                : 0;
     }
 
+    public int[] getSSTableCountPerLevel()
+    {
+        return compactionStrategy instanceof LeveledCompactionStrategy
+               ? ((LeveledCompactionStrategy) compactionStrategy).getAllLevelSize()
+               : null;
+    }
+
     public static class ViewFragment
     {
         public final List<SSTableReader> sstables;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c64d975c/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 b9fee05..9b18c23 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
@@ -323,4 +323,10 @@ public interface ColumnFamilyStoreMBean
      * @return the number of SSTables in L0.  Always return 0 if Leveled compaction is not
enabled.
      */
     public int getUnleveledSSTables();
+
+    /**
+     * @return sstable count for each level. null unless leveled compaction is used.
+     *         array index corresponds to level(int[0] is for level 0, ...).
+     */
+    public int[] getSSTableCountPerLevel();
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c64d975c/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
index f6b0d6d..ced79aa 100644
--- a/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
@@ -88,6 +88,11 @@ public class LeveledCompactionStrategy extends AbstractCompactionStrategy
implem
         return manifest.getLevelSize(i);
     }
 
+    public int[] getAllLevelSize()
+    {
+        return manifest.getAllLevelSize();
+    }
+
     /**
      * the only difference between background and maximal in LCS is that maximal is still
allowed
      * (by explicit user request) even when compaction is disabled.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c64d975c/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
index 9e1e8e4..1906180 100644
--- a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
+++ b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
@@ -314,6 +314,14 @@ public class LeveledManifest
         return generations.length > i ? generations[i].size() : 0;
     }
 
+    public synchronized int[] getAllLevelSize()
+    {
+        int[] counts = new int[generations.length];
+        for (int i = 0; i < counts.length; i++)
+            counts[i] = generations[i].size();
+        return counts;
+    }
+
     private void logDistribution()
     {
         if (logger.isDebugEnabled())

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c64d975c/src/java/org/apache/cassandra/tools/NodeCmd.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeCmd.java b/src/java/org/apache/cassandra/tools/NodeCmd.java
index 2359f76..b7dfb68 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -756,6 +756,27 @@ public class NodeCmd
             {
                 outs.println("\t\tColumn Family: " + cfstore.getColumnFamilyName());
                 outs.println("\t\tSSTable count: " + cfstore.getLiveSSTableCount());
+                int[] leveledSStables = cfstore.getSSTableCountPerLevel();
+                if (leveledSStables != null)
+                {
+                    outs.print("\t\tSSTables in each level: [");
+                    for (int level = 0; level < leveledSStables.length; level++)
+                    {
+                        int count = leveledSStables[level];
+                        outs.print(count);
+                        long maxCount = 4L; // for L0
+                        if (level > 0)
+                            maxCount = (long) Math.pow(10, level);
+                        //  show max threshold for level when exceeded
+                        if (count > maxCount)
+                            outs.print("/" + maxCount);
+
+                        if (level < leveledSStables.length - 1)
+                            outs.print(", ");
+                        else
+                            outs.println("]");
+                    }
+                }
                 outs.println("\t\tSpace used (live): " + cfstore.getLiveDiskSpaceUsed());
                 outs.println("\t\tSpace used (total): " + cfstore.getTotalDiskSpaceUsed());
                 outs.println("\t\tNumber of Keys (estimate): " + cfstore.estimateKeys());


Mime
View raw message