You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2011/02/18 23:10:33 UTC

svn commit: r1072169 - in /cassandra/branches/cassandra-0.7: ./ src/java/org/apache/cassandra/config/ src/java/org/apache/cassandra/db/

Author: jbellis
Date: Fri Feb 18 22:10:32 2011
New Revision: 1072169

URL: http://svn.apache.org/viewvc?rev=1072169&view=rev
Log:
update memtable_throughput to be a long
patch by jbellis; reviewed by brandonwilliams for CASSANDRA-2158

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/CFMetaData.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1072169&r1=1072168&r2=1072169&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Fri Feb 18 22:10:32 2011
@@ -11,6 +11,7 @@
    used for creating row keys (CASSANDRA-2108)
  * validate index names for \w+ (CASSANDRA-2196)
  * Fix Cassandra cli to respect timeout if schema does not settle (CASSANDRA-2187)
+ * update memtable_throughput to be a long (CASSANDRA-2158)
 
 
 0.7.2

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/CFMetaData.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/CFMetaData.java?rev=1072169&r1=1072168&r2=1072169&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/CFMetaData.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/CFMetaData.java Fri Feb 18 22:10:32 2011
@@ -207,6 +207,7 @@ public final class CFMetaData
         this.memtableThroughputInMb = memtableThroughputInMb == null
                                       ? DEFAULT_MEMTABLE_THROUGHPUT_IN_MB
                                       : memtableThroughputInMb;
+
         this.memtableOperationsInMillions = memtableOperationsInMillions == null
                                             ? DEFAULT_MEMTABLE_OPERATIONS_IN_MILLIONS
                                             : memtableOperationsInMillions;
@@ -881,28 +882,22 @@ public final class CFMetaData
 
     public static void validateMemtableSettings(org.apache.cassandra.thrift.CfDef cf_def) throws ConfigurationException
     {
-        if (cf_def.isSetMemtable_flush_after_mins() && cf_def.memtable_flush_after_mins <= 0) {
-            throw new ConfigurationException("memtable_flush_after_mins cannot be non-positive");
-        }
-        if (cf_def.isSetMemtable_throughput_in_mb() && cf_def.memtable_throughput_in_mb <= 0) {
-            throw new ConfigurationException("memtable_throughput_in_mb cannot be non-positive.");
-        }
-        if (cf_def.isSetMemtable_operations_in_millions() && cf_def.memtable_operations_in_millions <= 0) {
-            throw new ConfigurationException("memtable_operations_in_millions cannot be non-positive");
-        }
+        if (cf_def.isSetMemtable_flush_after_mins())
+            DatabaseDescriptor.validateMemtableFlushPeriod(cf_def.memtable_flush_after_mins);
+        if (cf_def.isSetMemtable_throughput_in_mb())
+            DatabaseDescriptor.validateMemtableThroughput(cf_def.memtable_throughput_in_mb);
+        if (cf_def.isSetMemtable_operations_in_millions())
+            DatabaseDescriptor.validateMemtableOperations(cf_def.memtable_operations_in_millions);
     }
 
     public static void validateMemtableSettings(org.apache.cassandra.avro.CfDef cf_def) throws ConfigurationException
     {
-        if (cf_def.memtable_flush_after_mins != null && cf_def.memtable_flush_after_mins <= 0) {
-            throw new ConfigurationException("memtable_flush_after_mins cannot be non-positive");
-        }
-        if (cf_def.memtable_throughput_in_mb != null && cf_def.memtable_throughput_in_mb <= 0) {
-            throw new ConfigurationException("memtable_throughput_in_mb cannot be non-positive.");
-        }
-        if (cf_def.memtable_operations_in_millions != null && cf_def.memtable_operations_in_millions <= 0) {
-            throw new ConfigurationException("memtable_operations_in_millions cannot be non-positive");
-        }
+        if (cf_def.memtable_flush_after_mins != null)
+            DatabaseDescriptor.validateMemtableFlushPeriod(cf_def.memtable_flush_after_mins);
+        if (cf_def.memtable_throughput_in_mb != null)
+            DatabaseDescriptor.validateMemtableThroughput(cf_def.memtable_throughput_in_mb);
+        if (cf_def.memtable_operations_in_millions != null)
+            DatabaseDescriptor.validateMemtableOperations(cf_def.memtable_operations_in_millions);
     }
 
     @Override

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=1072169&r1=1072168&r2=1072169&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/config/DatabaseDescriptor.java Fri Feb 18 22:10:32 2011
@@ -1179,4 +1179,24 @@ public class    DatabaseDescriptor
     {
         return conf.compaction_preheat_key_cache;
     }
+
+    public static void validateMemtableThroughput(int sizeInMB) throws ConfigurationException
+    {
+        if (sizeInMB <= 0)
+            throw new ConfigurationException("memtable_throughput_in_mb must be greater than 0.");
+    }
+
+    public static void validateMemtableOperations(double operationsInMillions) throws ConfigurationException
+    {
+        if (operationsInMillions <= 0)
+            throw new ConfigurationException("memtable_operations_in_millions must be greater than 0.0.");
+        if (operationsInMillions > Long.MAX_VALUE / 1024 * 1024)
+            throw new ConfigurationException("memtable_operations_in_millions must be less than " + Long.MAX_VALUE / 1024 * 1024);
+    }
+
+    public static void validateMemtableFlushPeriod(int minutes) throws ConfigurationException
+    {
+        if (minutes <= 0)
+            throw new ConfigurationException("memtable_flush_after_mins must be greater than 0.");
+    }
 }

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1072169&r1=1072168&r2=1072169&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Fri Feb 18 22:10:32 2011
@@ -39,6 +39,7 @@ import org.apache.cassandra.concurrent.N
 import org.apache.cassandra.concurrent.StageManager;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ColumnDefinition;
+import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.columniterator.IColumnIterator;
 import org.apache.cassandra.db.commitlog.CommitLog;
@@ -971,12 +972,12 @@ public class ColumnFamilyStore implement
         flushable.flushAndSignal(latch, flushSorter, flushWriter);
     }
 
-    public int getMemtableColumnsCount()
+    public long getMemtableColumnsCount()
     {
         return getMemtableThreadSafe().getCurrentOperations();
     }
 
-    public int getMemtableDataSize()
+    public long getMemtableDataSize()
     {
         return getMemtableThreadSafe().getCurrentThroughput();
     }
@@ -1944,24 +1945,20 @@ public class ColumnFamilyStore implement
     {
         return memsize.value();
     }
-    public void setMemtableThroughputInMB(int size)
+    public void setMemtableThroughputInMB(int size) throws ConfigurationException
     {
-        if (size <= 0) {
-            throw new RuntimeException("MemtableThroughputInMB must be greater than 0.");
-        }
-        this.memsize.set(size);
+        DatabaseDescriptor.validateMemtableThroughput(size);
+        memsize.set(size);
     }
 
     public double getMemtableOperationsInMillions()
     {
         return memops.value();
     }
-    public void setMemtableOperationsInMillions(double ops)
+    public void setMemtableOperationsInMillions(double ops) throws ConfigurationException
     {
-        if (ops <= 0) {
-            throw new RuntimeException("MemtableOperationsInMillions must be greater than 0.0.");
-        }
-        this.memops.set(ops);
+        DatabaseDescriptor.validateMemtableOperations(ops);
+        memops.set(ops);
     }
 
     public long estimateKeys()

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java?rev=1072169&r1=1072168&r2=1072169&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java Fri Feb 18 22:10:32 2011
@@ -22,6 +22,8 @@ import java.io.IOException;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 
+import org.apache.cassandra.config.ConfigurationException;
+
 /**
  * The MBean interface for ColumnFamilyStore
  */
@@ -38,14 +40,14 @@ public interface ColumnFamilyStoreMBean
      * 
      * @return The size in bytes.
      */
-    public int getMemtableDataSize();
+    public long getMemtableDataSize();
     
     /**
      * Returns the total number of columns present in the memtable.
      * 
      * @return The number of columns.
      */
-    public int getMemtableColumnsCount();
+    public long getMemtableColumnsCount();
     
     /**
      * Returns the number of times that a flush has resulted in the
@@ -211,10 +213,10 @@ public interface ColumnFamilyStoreMBean
     public void setMemtableFlushAfterMins(int time);
 
     public int getMemtableThroughputInMB();
-    public void setMemtableThroughputInMB(int size);
+    public void setMemtableThroughputInMB(int size) throws ConfigurationException;
 
     public double getMemtableOperationsInMillions();
-    public void setMemtableOperationsInMillions(double ops);
+    public void setMemtableOperationsInMillions(double ops) throws ConfigurationException;
 
     public long estimateKeys();
 

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java?rev=1072169&r1=1072168&r2=1072169&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java Fri Feb 18 22:10:32 2011
@@ -30,12 +30,14 @@ import java.util.concurrent.ConcurrentSk
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
 
 import com.google.common.collect.Iterators;
 import com.google.common.collect.PeekingIterator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.db.columniterator.IColumnIterator;
 import org.apache.cassandra.db.columniterator.SimpleAbstractColumnIterator;
 import org.apache.cassandra.db.filter.AbstractColumnIterator;
@@ -52,23 +54,23 @@ public class Memtable implements Compara
 
     private boolean isFrozen;
 
-    private final AtomicInteger currentThroughput = new AtomicInteger(0);
-    private final AtomicInteger currentOperations = new AtomicInteger(0);
+    private final AtomicLong currentThroughput = new AtomicLong(0);
+    private final AtomicLong currentOperations = new AtomicLong(0);
 
     private final long creationTime;
     private final ConcurrentNavigableMap<DecoratedKey, ColumnFamily> columnFamilies = new ConcurrentSkipListMap<DecoratedKey, ColumnFamily>();
     public final ColumnFamilyStore cfs;
 
-    private final int THRESHOLD;
-    private final int THRESHOLD_COUNT;
+    private final long THRESHOLD;
+    private final long THRESHOLD_COUNT;
 
     public Memtable(ColumnFamilyStore cfs)
     {
 
         this.cfs = cfs;
         creationTime = System.currentTimeMillis();
-        this.THRESHOLD = cfs.getMemtableThroughputInMB() * 1024 * 1024;
-        this.THRESHOLD_COUNT = (int) (cfs.getMemtableOperationsInMillions() * 1024 * 1024);
+        THRESHOLD = cfs.getMemtableThroughputInMB() * 1024 * 1024;
+        THRESHOLD_COUNT = (long) (cfs.getMemtableOperationsInMillions() * 1024 * 1024);
     }
 
     /**
@@ -88,12 +90,12 @@ public class Memtable implements Compara
     		return 0;
     }
 
-    public int getCurrentThroughput()
+    public long getCurrentThroughput()
     {
         return currentThroughput.get();
     }
     
-    public int getCurrentOperations()
+    public long getCurrentOperations()
     {
         return currentOperations.get();
     }