cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [2/5] cassandra git commit: Revert "Simplify row cache invalidation code"
Date Tue, 10 Nov 2015 13:46:31 GMT
Revert "Simplify row cache invalidation code"

This reverts commit d867ac1f41c59b31f8fb4f54a06c0118018cfc81.


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

Branch: refs/heads/cassandra-3.0
Commit: 48b685e8521ea54d93c0d8d9e4ea80ecb1400dce
Parents: d867ac1
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Mon Nov 9 20:15:44 2015 +0000
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Mon Nov 9 20:15:44 2015 +0000

----------------------------------------------------------------------
 .../org/apache/cassandra/db/ColumnFamilyStore.java   | 15 ++++++++++++---
 .../db/compaction/CompactionController.java          |  4 +++-
 .../cassandra/db/compaction/CompactionManager.java   |  2 +-
 .../apache/cassandra/io/sstable/SSTableRewriter.java |  3 ++-
 .../org/apache/cassandra/streaming/StreamReader.java |  2 +-
 test/unit/org/apache/cassandra/db/RowCacheTest.java  |  2 +-
 .../db/compaction/CompactionsPurgeTest.java          |  2 +-
 7 files changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/48b685e8/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 b112e0e..d553f4d 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1226,7 +1226,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         return String.format("%.2f/%.2f", onHeap, offHeap);
     }
 
-    public void maybeInvalidateCachedRow(DecoratedKey key)
+    public void maybeUpdateRowCache(DecoratedKey key)
     {
         if (!isRowCacheEnabled())
             return;
@@ -1247,7 +1247,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         long start = System.nanoTime();
         Memtable mt = data.getMemtableFor(opGroup, replayPosition);
         final long timeDelta = mt.put(key, columnFamily, indexer, opGroup);
-        maybeInvalidateCachedRow(key);
+        maybeUpdateRowCache(key);
         metric.samplers.get(Sampler.WRITES).addSample(key.getKey(), key.hashCode(), 1);
         metric.writeLatency.addNano(System.nanoTime() - start);
         if(timeDelta < Long.MAX_VALUE)
@@ -2047,7 +2047,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
             RowCacheKey key = keyIter.next();
             DecoratedKey dk = partitioner.decorateKey(ByteBuffer.wrap(key.key));
             if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(),
ranges))
-                maybeInvalidateCachedRow(dk);
+                invalidateCachedRow(dk);
         }
 
         if (metadata.isCounter())
@@ -2532,6 +2532,15 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         CacheService.instance.rowCache.remove(key);
     }
 
+    public void invalidateCachedRow(DecoratedKey key)
+    {
+        UUID cfId = Schema.instance.getId(keyspace.getName(), this.name);
+        if (cfId == null)
+            return; // secondary index
+
+        invalidateCachedRow(new RowCacheKey(metadata.ksAndCFName, key));
+    }
+
     public ClockAndCount getCachedCounter(ByteBuffer partitionKey, CellName cellName)
     {
         if (CacheService.instance.counterCache.getCapacity() == 0L) // counter cache disabled.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48b685e8/src/java/org/apache/cassandra/db/compaction/CompactionController.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionController.java b/src/java/org/apache/cassandra/db/compaction/CompactionController.java
index 24ef843..5f0a198 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionController.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionController.java
@@ -24,6 +24,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.db.ColumnFamilyStore;
+import org.apache.cassandra.db.lifecycle.SSTableIntervalTree;
+import org.apache.cassandra.db.lifecycle.Tracker;
 import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.RowPosition;
 import org.apache.cassandra.utils.AlwaysPresentFilter;
@@ -189,7 +191,7 @@ public class CompactionController implements AutoCloseable
 
     public void invalidateCachedRow(DecoratedKey key)
     {
-        cfs.maybeInvalidateCachedRow(key);
+        cfs.invalidateCachedRow(key);
     }
 
     public void close()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48b685e8/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
index 8537aca..0c6e24f 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -934,7 +934,7 @@ public class CompactionManager implements CompactionManagerMBean
                 if (Range.isInRanges(row.getKey().getToken(), ranges))
                     return row;
 
-                cfs.maybeInvalidateCachedRow(row.getKey());
+                cfs.invalidateCachedRow(row.getKey());
 
                 if (indexedColumnsInRow != null)
                     indexedColumnsInRow.clear();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48b685e8/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java b/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
index b08b038..dc4fe75 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
@@ -20,6 +20,7 @@ package org.apache.cassandra.io.sstable;
 import java.util.*;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.util.concurrent.Runnables;
 
 import org.apache.cassandra.cache.InstrumentingCache;
 import org.apache.cassandra.cache.KeyCacheKey;
@@ -118,7 +119,7 @@ public class SSTableRewriter extends Transactional.AbstractTransactional
impleme
         {
             if (index == null)
             {
-                cfs.maybeInvalidateCachedRow(row.key);
+                cfs.invalidateCachedRow(row.key);
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48b685e8/src/java/org/apache/cassandra/streaming/StreamReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/StreamReader.java b/src/java/org/apache/cassandra/streaming/StreamReader.java
index 88591da..1ccebb0 100644
--- a/src/java/org/apache/cassandra/streaming/StreamReader.java
+++ b/src/java/org/apache/cassandra/streaming/StreamReader.java
@@ -171,6 +171,6 @@ public class StreamReader
     {
         DecoratedKey key = StorageService.getPartitioner().decorateKey(ByteBufferUtil.readWithShortLength(in));
         writer.appendFromStream(key, cfs.metadata, in, inputVersion);
-        cfs.maybeInvalidateCachedRow(key);
+        cfs.invalidateCachedRow(key);
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48b685e8/test/unit/org/apache/cassandra/db/RowCacheTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RowCacheTest.java b/test/unit/org/apache/cassandra/db/RowCacheTest.java
index 69c831d..5912d7c 100644
--- a/test/unit/org/apache/cassandra/db/RowCacheTest.java
+++ b/test/unit/org/apache/cassandra/db/RowCacheTest.java
@@ -133,7 +133,7 @@ public class RowCacheTest
         int keysLeft = 109;
         for (int i = 109; i >= 10; i--)
         {
-            cachedStore.maybeInvalidateCachedRow(Util.dk("key" + i));
+            cachedStore.invalidateCachedRow(Util.dk("key" + i));
             assert CacheService.instance.rowCache.size() == keysLeft;
             keysLeft--;
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48b685e8/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java b/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
index bfe8042..e5baab6 100644
--- a/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
@@ -127,7 +127,7 @@ public class CompactionsPurgeTest
 
         // major compact and test that all columns but the resurrected one is completely
gone
         FBUtilities.waitOnFutures(CompactionManager.instance.submitMaximal(cfs, Integer.MAX_VALUE,
false));
-        cfs.maybeInvalidateCachedRow(key);
+        cfs.invalidateCachedRow(key);
         ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, cfName,
System.currentTimeMillis()));
         assertColumns(cf, "5");
         assertNotNull(cf.getColumn(cellname(String.valueOf(5))));


Mime
View raw message