cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1151211 - in /cassandra/trunk: src/java/org/apache/cassandra/db/ColumnFamilyStore.java test/unit/org/apache/cassandra/db/RowCacheTest.java
Date Tue, 26 Jul 2011 18:58:25 GMT
Author: jbellis
Date: Tue Jul 26 18:58:24 2011
New Revision: 1151211

URL: http://svn.apache.org/viewvc?rev=1151211&view=rev
Log:
stop reading cache after max size-to-save is reached
patch by Chris Burroughs; reviewed by jbellis for CASSANDRA-2082

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RowCacheTest.java

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=1151211&r1=1151210&r2=1151211&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Tue Jul 26 18:58:24
2011
@@ -537,8 +537,16 @@ public class ColumnFamilyStore implement
     {
         long start = System.currentTimeMillis();
         // results are sorted on read (via treeset) because there are few reads and many
writes and reads only happen at startup
+        int cachedRowsRead = 0;
         for (DecoratedKey key : rowCache.readSaved())
+        {
             cacheRow(key);
+            if (cachedRowsRead++ > rowCache.getCapacity())
+            {
+                logger.debug(String.format("Stopped loading row cache after capacity %d was
reached", rowCache.getCapacity()));
+                break;
+            }
+        }
         if (rowCache.size() > 0)
             logger.info(String.format("completed loading (%d ms; %d keys) row cache for %s.%s",
                                       System.currentTimeMillis()-start,

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/RowCacheTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/RowCacheTest.java?rev=1151211&r1=1151210&r2=1151211&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/RowCacheTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/RowCacheTest.java Tue Jul 26 18:58:24
2011
@@ -114,18 +114,24 @@ public class RowCacheTest extends Cleanu
     @Test
     public void testRowCacheLoad() throws Exception
     {
-        rowCacheLoad(100, 100, Integer.MAX_VALUE);
+        rowCacheLoad(100, 100, Integer.MAX_VALUE, false);
     }
 
-
     @Test
     public void testRowCachePartialLoad() throws Exception
     {
-        rowCacheLoad(100, 50, 50);
+        rowCacheLoad(100, 50, 50, false);
+    }
+
+    @Test
+    public void testRowCacheCapacityLoad() throws Exception
+    {
+        // 60 is default from DatabaseDescriptor
+        rowCacheLoad(100, 60, Integer.MAX_VALUE, true);
     }
 
 
-    public void rowCacheLoad(int totalKeys, int expectedKeys, int keysToSave) throws Exception
+    public void rowCacheLoad(int totalKeys, int expectedKeys, int keysToSave, boolean reduceLoadCapacity)
throws Exception
     {
         CompactionManager.instance.disableAutoCompaction();
 
@@ -143,6 +149,9 @@ public class RowCacheTest extends Cleanu
         // force the cache to disk
         store.rowCache.submitWrite(keysToSave).get();
 
+        if (reduceLoadCapacity)
+            store.reduceCacheSizes();
+
         // empty the cache again to make sure values came from disk
         store.invalidateRowCache();
         assert store.getRowCacheSize() == 0;



Mime
View raw message