cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject [01/12] cassandra git commit: Don't track hotness when opening from snapshot for validation
Date Tue, 28 Jul 2015 23:56:34 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 573a1d115 -> 878d61642
  refs/heads/cassandra-2.1 94c826e85 -> 739520752
  refs/heads/cassandra-2.2 0ba915d93 -> a96b207c3
  refs/heads/trunk 59a28615c -> 3e75d5a62


Don't track hotness when opening from snapshot for validation

patch by yukim; reveiwed by benedict for CASSANDRA-9382


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

Branch: refs/heads/cassandra-2.0
Commit: 878d6164278257fae05adba7402d849b7735162e
Parents: 573a1d1
Author: Yuki Morishita <yukim@apache.org>
Authored: Tue Jul 28 13:47:08 2015 -0500
Committer: Yuki Morishita <yukim@apache.org>
Committed: Tue Jul 28 13:47:33 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/db/ColumnFamilyStore.java  |  3 +-
 .../cassandra/io/sstable/SSTableReader.java     | 74 ++++++++++++--------
 3 files changed, 47 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/878d6164/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 12af151..5ce2cc7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -19,6 +19,7 @@
  * Display min timestamp in sstablemetadata viewer (CASSANDRA-6767)
  * Scrub (recover) sstables even when -Index.db is missing, (CASSANDRA-9591)
  * Fix growing pending background compaction (CASSANDRA-9662)
+ * Don't track hotness when opening from snapshot for validation (CASSANDRA-9382)
 
 
 2.0.16

http://git-wip-us.apache.org/repos/asf/cassandra/blob/878d6164/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 00b2eb8..c125cf0 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1890,7 +1890,8 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
                 {
                     if (logger.isDebugEnabled())
                         logger.debug("using snapshot sstable {}", entries.getKey());
-                    sstable = SSTableReader.open(entries.getKey(), entries.getValue(), metadata,
partitioner);
+                    // open without tracking hotness
+                    sstable = SSTableReader.open(entries.getKey(), entries.getValue(), metadata,
partitioner, true, false);
                     // This is technically not necessary since it's a snapshot but makes
things easier
                     sstable.acquireReference();
                 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/878d6164/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
index 8919a09..39d46e9 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
@@ -66,6 +66,11 @@ public class SSTableReader extends SSTable implements Closeable
     private static final Logger logger = LoggerFactory.getLogger(SSTableReader.class);
 
     private static final ScheduledThreadPoolExecutor syncExecutor = new ScheduledThreadPoolExecutor(1);
+    static
+    {
+        // Immediately remove readMeter sync task when cancelled.
+        syncExecutor.setRemoveOnCancelPolicy(true);
+    }
     private static final RateLimiter meterSyncThrottle = RateLimiter.create(100.0);
 
     /**
@@ -107,7 +112,7 @@ public class SSTableReader extends SSTable implements Closeable
 
     @VisibleForTesting
     public RestorableMeter readMeter;
-    private ScheduledFuture readMeterSyncFuture;
+    private final ScheduledFuture readMeterSyncFuture;
 
     public static long getApproximateKeyCount(Iterable<SSTableReader> sstables, CFMetaData
metadata)
     {
@@ -152,7 +157,7 @@ public class SSTableReader extends SSTable implements Closeable
 
     public static SSTableReader openNoValidation(Descriptor descriptor, Set<Component>
components, CFMetaData metadata) throws IOException
     {
-        return open(descriptor, components, metadata, StorageService.getPartitioner(), false);
+        return open(descriptor, components, metadata, StorageService.getPartitioner(), false,
false); // do not track hotness
     }
 
     public static SSTableReader openForBatch(Descriptor descriptor, Set<Component>
components, CFMetaData metadata, IPartitioner partitioner) throws IOException
@@ -163,7 +168,8 @@ public class SSTableReader extends SSTable implements Closeable
                                                   metadata,
                                                   partitioner,
                                                   System.currentTimeMillis(),
-                                                  sstableMetadata);
+                                                  sstableMetadata,
+                                                  false); // we don't need to track hotness
when using for batch
 
         // special implementation of load to use non-pooled SegmentedFile builders
         SegmentedFile.Builder ibuilder = new BufferedSegmentedFile.Builder();
@@ -181,14 +187,18 @@ public class SSTableReader extends SSTable implements Closeable
 
     public static SSTableReader open(Descriptor descriptor, Set<Component> components,
CFMetaData metadata, IPartitioner partitioner) throws IOException
     {
-        return open(descriptor, components, metadata, partitioner, true);
+        // Don't track read rates for tables in the system keyspace and don't bother trying
to load or persist
+        // the read meter when in client mode
+        boolean trackHotness = !(Keyspace.SYSTEM_KS.equals(descriptor.ksname) || Config.isClientMode());
+        return open(descriptor, components, metadata, partitioner, true, trackHotness);
     }
 
-    private static SSTableReader open(Descriptor descriptor,
+    public static SSTableReader open(Descriptor descriptor,
                                       Set<Component> components,
                                       CFMetaData metadata,
                                       IPartitioner partitioner,
-                                      boolean validate) throws IOException
+                                      boolean validate,
+                                      boolean trackHotness) throws IOException
     {
         long start = System.nanoTime();
         SSTableMetadata sstableMetadata = openMetadata(descriptor, components, partitioner,
validate);
@@ -198,7 +208,8 @@ public class SSTableReader extends SSTable implements Closeable
                                                   metadata,
                                                   partitioner,
                                                   System.currentTimeMillis(),
-                                                  sstableMetadata);
+                                                  sstableMetadata,
+                                                  trackHotness);
 
         sstable.load();
 
@@ -308,6 +319,7 @@ public class SSTableReader extends SSTable implements Closeable
                                       SSTableMetadata sstableMetadata)
     {
         assert desc != null && partitioner != null && ifile != null &&
dfile != null && isummary != null && bf != null && sstableMetadata
!= null;
+        boolean trackHotness = !(Keyspace.SYSTEM_KS.equals(desc.ksname) || Config.isClientMode());
         return new SSTableReader(desc,
                                  components,
                                  metadata,
@@ -316,7 +328,8 @@ public class SSTableReader extends SSTable implements Closeable
                                  isummary,
                                  bf,
                                  maxDataAge,
-                                 sstableMetadata);
+                                 sstableMetadata,
+                                 trackHotness);
     }
 
 
@@ -325,7 +338,8 @@ public class SSTableReader extends SSTable implements Closeable
                           CFMetaData metadata,
                           IPartitioner partitioner,
                           long maxDataAge,
-                          SSTableMetadata sstableMetadata)
+                          SSTableMetadata sstableMetadata,
+                          boolean trackHotness)
     {
         super(desc, components, metadata, partitioner);
         this.sstableMetadata = sstableMetadata;
@@ -333,28 +347,27 @@ public class SSTableReader extends SSTable implements Closeable
 
         deletingTask = new SSTableDeletingTask(this);
 
-        // Don't track read rates for tables in the system keyspace and don't bother trying
to load or persist
-        // the read meter when in client mode
-        if (Keyspace.SYSTEM_KS.equals(desc.ksname) || Config.isClientMode())
-        {
-            readMeter = null;
-            readMeterSyncFuture = null;
-            return;
-        }
-
-        readMeter = SystemKeyspace.getSSTableReadMeter(desc.ksname, desc.cfname, desc.generation);
-        // sync the average read rate to system.sstable_activity every five minutes, starting
one minute from now
-        readMeterSyncFuture = syncExecutor.scheduleAtFixedRate(new Runnable()
+        if (trackHotness)
         {
-            public void run()
+            readMeter = SystemKeyspace.getSSTableReadMeter(desc.ksname, desc.cfname, desc.generation);
+            // sync the average read rate to system.sstable_activity every five minutes,
starting one minute from now
+            readMeterSyncFuture = syncExecutor.scheduleAtFixedRate(new Runnable()
             {
-                if (!isCompacted.get())
+                public void run()
                 {
-                    meterSyncThrottle.acquire();
-                    SystemKeyspace.persistSSTableReadMeter(desc.ksname, desc.cfname, desc.generation,
readMeter);
+                    if (!isCompacted.get())
+                    {
+                        meterSyncThrottle.acquire();
+                        SystemKeyspace.persistSSTableReadMeter(desc.ksname, desc.cfname,
desc.generation, readMeter);
+                    }
                 }
-            }
-        }, 1, 5, TimeUnit.MINUTES);
+            }, 1, 5, TimeUnit.MINUTES);
+        }
+        else
+        {
+            readMeter = null;
+            readMeterSyncFuture = null;
+        }
     }
 
     private SSTableReader(Descriptor desc,
@@ -366,9 +379,10 @@ public class SSTableReader extends SSTable implements Closeable
                           IndexSummary indexSummary,
                           IFilter bloomFilter,
                           long maxDataAge,
-                          SSTableMetadata sstableMetadata)
+                          SSTableMetadata sstableMetadata,
+                          boolean trackHotness)
     {
-        this(desc, components, metadata, partitioner, maxDataAge, sstableMetadata);
+        this(desc, components, metadata, partitioner, maxDataAge, sstableMetadata, trackHotness);
 
         this.ifile = ifile;
         this.dfile = dfile;
@@ -384,7 +398,7 @@ public class SSTableReader extends SSTable implements Closeable
     public void close() throws IOException
     {
         if (readMeterSyncFuture != null)
-            readMeterSyncFuture.cancel(false);
+            readMeterSyncFuture.cancel(true);
 
         // Force finalizing mmapping if necessary
 


Mime
View raw message