cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [1/6] cassandra git commit: Allow compaction strategies to disable early open
Date Fri, 13 May 2016 07:49:49 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 78a3d2bba -> eda763b47
  refs/heads/cassandra-3.7 590d20b0a -> baaf74616
  refs/heads/trunk 3f46df541 -> 0c09bc85c


Allow compaction strategies to disable early open

Patch by Blake Eggleston; reviewed by Marcus Eriksson for CASSANDRA-11754


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

Branch: refs/heads/cassandra-3.0
Commit: eda763b473abddc90e06e95661cd448f41da07ea
Parents: 78a3d2b
Author: Blake Eggleston <bdeggleston@gmail.com>
Authored: Wed May 11 13:49:19 2016 -0700
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Fri May 13 09:33:45 2016 +0200

----------------------------------------------------------------------
 CHANGES.txt                                                    | 1 +
 src/java/org/apache/cassandra/db/ColumnFamilyStore.java        | 5 +++++
 .../cassandra/db/compaction/AbstractCompactionStrategy.java    | 5 +++++
 .../org/apache/cassandra/db/compaction/CompactionManager.java  | 2 +-
 .../cassandra/db/compaction/CompactionStrategyManager.java     | 5 +++++
 src/java/org/apache/cassandra/db/compaction/Scrubber.java      | 2 +-
 src/java/org/apache/cassandra/db/compaction/Upgrader.java      | 2 +-
 .../cassandra/db/compaction/writers/CompactionAwareWriter.java | 3 +--
 src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java  | 6 ++++++
 9 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/eda763b4/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 677ea11..4361ab4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.7
+ * Allow compaction strategies to disable early open (CASSANDRA-11754)
  * Refactor Materialized View code (CASSANDRA-11475)
  * Update Java Driver (CASSANDRA-11615)
 Merged from 2.2:

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eda763b4/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 e9a2938..98ba781 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -475,6 +475,11 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         return getCompactionStrategyManager().createSSTableMultiWriter(descriptor, keyCount,
repairedAt, metadataCollector, header, txn);
     }
 
+    public boolean supportsEarlyOpen()
+    {
+        return compactionStrategyManager.supportsEarlyOpen();
+    }
+
     /** call when dropping or renaming a CF. Performs mbean housekeeping and invalidates
CFS to other operations */
     public void invalidate()
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eda763b4/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
index 8928db5..c29e88e 100644
--- a/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
@@ -515,4 +515,9 @@ public abstract class AbstractCompactionStrategy
     {
         return SimpleSSTableMultiWriter.create(descriptor, keyCount, repairedAt, cfs.metadata,
meta, header, txn);
     }
+
+    public boolean supportsEarlyOpen()
+    {
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eda763b4/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 63b3cd5..e6208ad 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -864,7 +864,7 @@ public class CompactionManager implements CompactionManagerMBean
 
         List<SSTableReader> finished;
         int nowInSec = FBUtilities.nowInSeconds();
-        try (SSTableRewriter writer = new SSTableRewriter(txn, sstable.maxDataAge, false);
+        try (SSTableRewriter writer = SSTableRewriter.construct(cfs, txn, false, sstable.maxDataAge,
false);
              ISSTableScanner scanner = cleanupStrategy.getScanner(sstable, getRateLimiter());
              CompactionController controller = new CompactionController(cfs, txn.originals(),
getDefaultGcBefore(cfs, nowInSec));
              CompactionIterator ci = new CompactionIterator(OperationType.CLEANUP, Collections.singletonList(scanner),
controller, nowInSec, UUIDGen.getTimeUUID(), metrics))

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eda763b4/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
index f1127c9..444d43d 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionStrategyManager.java
@@ -498,4 +498,9 @@ public class CompactionStrategyManager implements INotificationConsumer
             return repaired.createSSTableMultiWriter(descriptor, keyCount, repairedAt, collector,
header, txn);
         }
     }
+
+    public boolean supportsEarlyOpen()
+    {
+        return repaired.supportsEarlyOpen();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eda763b4/src/java/org/apache/cassandra/db/compaction/Scrubber.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/Scrubber.java b/src/java/org/apache/cassandra/db/compaction/Scrubber.java
index 3dea9d9..d824d04 100644
--- a/src/java/org/apache/cassandra/db/compaction/Scrubber.java
+++ b/src/java/org/apache/cassandra/db/compaction/Scrubber.java
@@ -147,7 +147,7 @@ public class Scrubber implements Closeable
         List<SSTableReader> finished = new ArrayList<>();
         boolean completed = false;
         outputHandler.output(String.format("Scrubbing %s (%s bytes)", sstable, dataFile.length()));
-        try (SSTableRewriter writer = new SSTableRewriter(transaction, sstable.maxDataAge,
transaction.isOffline()))
+        try (SSTableRewriter writer = SSTableRewriter.construct(cfs, transaction, false,
sstable.maxDataAge, transaction.isOffline()))
         {
             nextIndexKey = indexAvailable() ? ByteBufferUtil.readWithShortLength(indexFile)
: null;
             if (indexAvailable())

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eda763b4/src/java/org/apache/cassandra/db/compaction/Upgrader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/Upgrader.java b/src/java/org/apache/cassandra/db/compaction/Upgrader.java
index fcd1a3c..822bb85 100644
--- a/src/java/org/apache/cassandra/db/compaction/Upgrader.java
+++ b/src/java/org/apache/cassandra/db/compaction/Upgrader.java
@@ -82,7 +82,7 @@ public class Upgrader
     {
         outputHandler.output("Upgrading " + sstable);
         int nowInSec = FBUtilities.nowInSeconds();
-        try (SSTableRewriter writer = SSTableRewriter.constructKeepingOriginals(transaction,
keepOriginals, CompactionTask.getMaxDataAge(transaction.originals()), true);
+        try (SSTableRewriter writer = SSTableRewriter.construct(cfs, transaction, keepOriginals,
CompactionTask.getMaxDataAge(transaction.originals()), true);
              AbstractCompactionStrategy.ScannerList scanners = strategyManager.getScanners(transaction.originals());
              CompactionIterator iter = new CompactionIterator(transaction.opType(), scanners.scanners,
controller, nowInSec, UUIDGen.getTimeUUID()))
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eda763b4/src/java/org/apache/cassandra/db/compaction/writers/CompactionAwareWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/writers/CompactionAwareWriter.java
b/src/java/org/apache/cassandra/db/compaction/writers/CompactionAwareWriter.java
index 0b3b7d0..d33d72c 100644
--- a/src/java/org/apache/cassandra/db/compaction/writers/CompactionAwareWriter.java
+++ b/src/java/org/apache/cassandra/db/compaction/writers/CompactionAwareWriter.java
@@ -63,8 +63,7 @@ public abstract class CompactionAwareWriter extends Transactional.AbstractTransa
         this.maxAge = CompactionTask.getMaxDataAge(nonExpiredSSTables);
         this.minRepairedAt = CompactionTask.getMinRepairedAt(nonExpiredSSTables);
         this.txn = txn;
-        this.sstableWriter = SSTableRewriter.constructKeepingOriginals(txn, keepOriginals,
maxAge, offline);
-
+        this.sstableWriter = SSTableRewriter.construct(cfs, txn, keepOriginals, maxAge, offline);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eda763b4/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 e652b9d..f4a2e1b 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
@@ -25,6 +25,7 @@ import com.google.common.annotations.VisibleForTesting;
 import org.apache.cassandra.cache.InstrumentingCache;
 import org.apache.cassandra.cache.KeyCacheKey;
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.db.ColumnFamilyStore;
 import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.RowIndexEntry;
 import org.apache.cassandra.db.rows.UnfilteredRowIterator;
@@ -98,6 +99,11 @@ public class SSTableRewriter extends Transactional.AbstractTransactional
impleme
         return new SSTableRewriter(transaction, maxAge, isOffline, calculateOpenInterval(true),
keepOriginals);
     }
 
+    public static SSTableRewriter construct(ColumnFamilyStore cfs, LifecycleTransaction transaction,
boolean keepOriginals, long maxAge, boolean isOffline)
+    {
+        return new SSTableRewriter(transaction, maxAge, isOffline, calculateOpenInterval(cfs.supportsEarlyOpen()),
keepOriginals);
+    }
+
     private static long calculateOpenInterval(boolean shouldOpenEarly)
     {
         long interval = DatabaseDescriptor.getSSTablePreempiveOpenIntervalInMB() * (1L <<
20);


Mime
View raw message