cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1026207 - in /cassandra/trunk: ./ src/java/org/apache/cassandra/db/
Date Fri, 22 Oct 2010 03:53:30 GMT
Author: jbellis
Date: Fri Oct 22 03:53:29 2010
New Revision: 1026207

URL: http://svn.apache.org/viewvc?rev=1026207&view=rev
Log:
add memtable settings to CFS mbean.  patch by Jon Hermes; reviewed by jbellis for CASSANDRA-1637

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Table.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1026207&r1=1026206&r2=1026207&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Fri Oct 22 03:53:29 2010
@@ -39,7 +39,8 @@ dev
  * PropertyFileSnitch configuration file renamed to 
    cassandra-topology.properties
  * add cli support for get_range_slices (CASSANDRA-1088, CASSANDRA-1619)
- * Make memtable flush thresholds per-CF instead of global (CASSANDRA-1007)
+ * Make memtable flush thresholds per-CF instead of global 
+   (CASSANDRA-1007, 1637)
  * add cli support for binary data without CfDef hints (CASSANDRA-1603)
  * fix building SSTable statistics post-stream (CASSANDRA-1620)
  * fix potential infinite loop in 2ary index queries (CASSANDRA-1623)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1026207&r1=1026206&r2=1026207&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Fri Oct 22 03:53:29
2010
@@ -183,6 +183,9 @@ public class ColumnFamilyStore implement
     /* These are locally held copies to be changed from the config during runtime */
     private int minCompactionThreshold;
     private int maxCompactionThreshold;
+    private int memtime;
+    private int memsize;
+    private double memops;
 
     private final Runnable rowCacheSaverTask = new WrappedRunnable()
     {
@@ -208,6 +211,9 @@ public class ColumnFamilyStore implement
         this.metadata = metadata;
         this.minCompactionThreshold = metadata.minCompactionThreshold;
         this.maxCompactionThreshold = metadata.maxCompactionThreshold;
+        this.memtime = metadata.memtableFlushAfterMins;
+        this.memsize = metadata.memtableThroughputInMb;
+        this.memops = metadata.memtableOperationsInMillions;
         this.partitioner = partitioner;
         fileIndexGenerator.set(generation);
         memtable = new Memtable(this);
@@ -580,7 +586,7 @@ public class ColumnFamilyStore implement
      */
     public String getFlushPath()
     {
-        long guessedSize = 2 * metadata.memtableThroughputInMb * 1024*1024; // 2* adds room
for keys, column indexes
+        long guessedSize = 2 * memsize * 1024*1024; // 2* adds room for keys, column indexes
         String location = DatabaseDescriptor.getDataFileLocationForTable(table.name, guessedSize);
         if (location == null)
             throw new RuntimeException("Insufficient disk space to flush");
@@ -1831,7 +1837,6 @@ public class ColumnFamilyStore implement
     
     public void setMinimumCompactionThreshold(int minCompactionThreshold)
     {
-        //TODO: If someone complains this is too rude, make it more friendly.
         if ((minCompactionThreshold > this.maxCompactionThreshold) && this.maxCompactionThreshold
!= 0) {
             throw new RuntimeException("The min_compaction_threshold cannot be larger than
the max.");
         }
@@ -1845,7 +1850,6 @@ public class ColumnFamilyStore implement
 
     public void setMaximumCompactionThreshold(int maxCompactionThreshold)
     {
-        //TODO: If someone complains this is too rude, make it more friendly.
         if (maxCompactionThreshold < this.minCompactionThreshold) {
             throw new RuntimeException("The max_compaction_threshold cannot be smaller than
the min.");
         }
@@ -1857,4 +1861,40 @@ public class ColumnFamilyStore implement
         this.minCompactionThreshold = 0;
         this.maxCompactionThreshold = 0;
     }
+
+    public int getMemtableFlushAfterMins()
+    {
+        return memtime;
+    }
+    public void setMemtableFlushAfterMins(int time)
+    {
+        if (time <= 0) {
+            throw new RuntimeException("MemtableFlushAfterMins must be greater than 0.");
+        }
+        this.memtime = time;
+    }
+
+    public int getMemtableThroughputInMB()
+    {
+        return memsize;
+    }
+    public void setMemtableThroughputInMB(int size)
+    {
+        if (size <= 0) {
+            throw new RuntimeException("MemtableThroughputInMB must be greater than 0.");
+        }
+        this.memsize = size;
+    }
+
+    public double getMemtableOperationsInMillions()
+    {
+        return memops;
+    }
+    public void setMemtableOperationsInMillions(double ops)
+    {
+        if (ops <= 0) {
+            throw new RuntimeException("MemtableOperationsInMillions must be greater than
0.0.");
+        }
+        this.memops = ops;
+    }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java?rev=1026207&r1=1026206&r2=1026207&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java Fri Oct 22
03:53:29 2010
@@ -201,4 +201,13 @@ public interface ColumnFamilyStoreMBean
      * Disable automatic compaction.
      */
     public void disableAutoCompaction();
+
+    public int getMemtableFlushAfterMins();
+    public void setMemtableFlushAfterMins(int time);
+
+    public int getMemtableThroughputInMB();
+    public void setMemtableThroughputInMB(int size);
+
+    public double getMemtableOperationsInMillions();
+    public void setMemtableOperationsInMillions(double ops);
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java?rev=1026207&r1=1026206&r2=1026207&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java Fri Oct 22 03:53:29 2010
@@ -66,8 +66,8 @@ public class Memtable implements Compara
 
         this.cfs = cfs;
         creationTime = System.currentTimeMillis();
-        this.THRESHOLD = cfs.metadata.memtableThroughputInMb * 1024 * 1024;
-        this.THRESHOLD_COUNT = (int) (cfs.metadata.memtableOperationsInMillions * 1024 *
1024);
+        this.THRESHOLD = cfs.getMemtableThroughputInMB() * 1024 * 1024;
+        this.THRESHOLD_COUNT = (int) (cfs.getMemtableOperationsInMillions() * 1024 * 1024);
     }
 
     /**
@@ -294,6 +294,6 @@ public class Memtable implements Compara
 
     public boolean isExpired()
     {
-        return System.currentTimeMillis() > creationTime + cfs.metadata.memtableFlushAfterMins
* 60 * 1000;
+        return System.currentTimeMillis() > creationTime + cfs.getMemtableFlushAfterMins()
* 60 * 1000;
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=1026207&r1=1026206&r2=1026207&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Fri Oct 22 03:53:29 2010
@@ -263,7 +263,7 @@ public class Table
         int minCheckMs = Integer.MAX_VALUE;
         for (ColumnFamilyStore cfs : columnFamilyStores.values())
         {
-            minCheckMs = Math.min(minCheckMs, cfs.metadata.memtableFlushAfterMins * 60 *
1000);
+            minCheckMs = Math.min(minCheckMs, cfs.getMemtableFlushAfterMins() * 60 * 1000);
         }
 
         Runnable runnable = new Runnable()



Mime
View raw message