Author: jbellis
Date: Tue Apr 14 15:47:44 2009
New Revision: 764841

URL: http://svn.apache.org/viewvc?rev=764841&view=rev
Log:
an MBean attribute for displaying a flush counter

This changeset adds a new attribute to the ColumnFamilyStore MBean which
displays the number of times the memtable has been "switched". This
attribute (along with the newly added count and size attributes),
should prove useful in tuning thresholds.

patch by Eric Evans; reviewed by jbellis for #75

for your changes.

Modified:
    incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStore.java
    
incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStoreMBean.java

Modified: 
incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStore.java
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStore.java?rev=764841&r1=764840&r2=764841&view=diff
==============================================================================
--- 
incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStore.java 
(original)
+++ 
incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStore.java 
Tue Apr 14 15:47:44 2009
@@ -68,6 +68,8 @@
 
     private String table_;
     public String columnFamily_;
+    
+    private volatile Integer memtableSwitchCount = 0;
 
     /* This is used to generate the next index for a SSTable */
     private AtomicInteger fileIndexGenerator_ = new AtomicInteger(0);
@@ -395,6 +397,12 @@
         memtable_.set( new Memtable(table_, columnFamily_) );
         if(!key.equals(Memtable.flushKey_))
                memtable_.get().put(key, columnFamily, cLogCtx);
+        
+        if (memtableSwitchCount == Integer.MAX_VALUE)
+        {
+            memtableSwitchCount = 0;
+        }
+        memtableSwitchCount++;
     }
 
     /*
@@ -1380,4 +1388,9 @@
     {
         return memtable_.get().getCurrentSize();
     }
+
+    public int getMemtableSwitchCount()
+    {
+        return memtableSwitchCount;
+    }
 }

Modified: 
incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStoreMBean.java?rev=764841&r1=764840&r2=764841&view=diff
==============================================================================
--- 
incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
 (original)
+++ 
incubator/cassandra/trunk/src/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
 Tue Apr 14 15:47:44 2009
@@ -40,4 +40,12 @@
      * @return The number of columns.
      */
     public int getMemtableColumnsCount();
+    
+    /**
+     * Returns the number of times that a flush has resulted in the 
+     * memtable being switched out.
+     * 
+     * @return the number of memtable switches
+     */
+    public int getMemtableSwitchCount();
 }


Reply via email to