cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject cassandra git commit: Fix handling of enable/disable autocompaction.
Date Wed, 29 Jul 2015 15:12:28 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 739520752 -> dce303bcb


Fix handling of enable/disable autocompaction.

Patch by marcuse; reviewed by Jeremiah Jordan for CASSANDRA-9899


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

Branch: refs/heads/cassandra-2.1
Commit: dce303bcb5748d302448769177a245a30ec3cc19
Parents: 7395207
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Mon Jul 27 09:31:08 2015 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Wed Jul 29 15:58:21 2015 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../compaction/AbstractCompactionStrategy.java  |  2 +-
 .../DateTieredCompactionStrategy.java           |  5 +---
 .../compaction/LeveledCompactionStrategy.java   |  2 --
 .../SizeTieredCompactionStrategy.java           |  6 ----
 .../compaction/WrappingCompactionStrategy.java  | 30 +++++++++++++++++++-
 6 files changed, 32 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/dce303bc/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c4bb21c..4ef77ed 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.9
+ * Fix handling of enable/disable autocompaction (CASSANDRA-9899)
  * Commit log segment recycling is disabled by default (CASSANDRA-9896)
  * Add consistency level to tracing ouput (CASSANDRA-9827)
  * Fix MarshalException when upgrading superColumn family (CASSANDRA-9582)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/dce303bc/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 9eac2d0..73cda77 100644
--- a/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
@@ -60,7 +60,7 @@ public abstract class AbstractCompactionStrategy
     protected static final String UNCHECKED_TOMBSTONE_COMPACTION_OPTION = "unchecked_tombstone_compaction";
     protected static final String COMPACTION_ENABLED = "enabled";
 
-    public final Map<String, String> options;
+    protected Map<String, String> options;
 
     protected final ColumnFamilyStore cfs;
     protected float tombstoneThreshold;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/dce303bc/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategy.java
b/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategy.java
index 15287bd..dec0cef 100644
--- a/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/DateTieredCompactionStrategy.java
@@ -57,9 +57,6 @@ public class DateTieredCompactionStrategy extends AbstractCompactionStrategy
     @Override
     public synchronized AbstractCompactionTask getNextBackgroundTask(int gcBefore)
     {
-        if (!isEnabled())
-            return null;
-
         while (true)
         {
             List<SSTableReader> latestBucket = getNextBackgroundSSTables(gcBefore);
@@ -79,7 +76,7 @@ public class DateTieredCompactionStrategy extends AbstractCompactionStrategy
      */
     private List<SSTableReader> getNextBackgroundSSTables(final int gcBefore)
     {
-        if (!isEnabled() || cfs.getSSTables().isEmpty())
+        if (cfs.getSSTables().isEmpty())
             return Collections.emptyList();
 
         Set<SSTableReader> uncompacting = Sets.intersection(sstables, cfs.getUncompactingSSTables());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/dce303bc/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
index f9e5d16..8afe6b6 100644
--- a/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
@@ -87,8 +87,6 @@ public class LeveledCompactionStrategy extends AbstractCompactionStrategy
      */
     public synchronized AbstractCompactionTask getNextBackgroundTask(int gcBefore)
     {
-        if (!isEnabled())
-            return null;
         Collection<AbstractCompactionTask> tasks = getMaximalTask(gcBefore);
         if (tasks == null || tasks.size() == 0)
             return null;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/dce303bc/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
index 93484e8..1f4acdb 100644
--- a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
@@ -75,9 +75,6 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
 
     private List<SSTableReader> getNextBackgroundSSTables(final int gcBefore)
     {
-        if (!isEnabled())
-            return Collections.emptyList();
-
         // make local copies so they can't be changed out from under us mid-method
         int minThreshold = cfs.getMinimumCompactionThreshold();
         int maxThreshold = cfs.getMaximumCompactionThreshold();
@@ -177,9 +174,6 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
 
     public synchronized AbstractCompactionTask getNextBackgroundTask(int gcBefore)
     {
-        if (!isEnabled())
-            return null;
-
         while (true)
         {
             List<SSTableReader> hottestBucket = getNextBackgroundSSTables(gcBefore);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/dce303bc/src/java/org/apache/cassandra/db/compaction/WrappingCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/WrappingCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/WrappingCompactionStrategy.java
index 2f8bd7c..e01b4c6 100644
--- a/src/java/org/apache/cassandra/db/compaction/WrappingCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/WrappingCompactionStrategy.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Callable;
 
+import com.google.common.collect.ImmutableMap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -150,18 +151,23 @@ public final class WrappingCompactionStrategy extends AbstractCompactionStrategy
             && repaired.options.equals(metadata.compactionStrategyOptions)
             && unrepaired.options.equals(metadata.compactionStrategyOptions))
             return;
-
         reloadCompactionStrategy(metadata);
     }
 
     public synchronized void reloadCompactionStrategy(CFMetaData metadata)
     {
+        boolean disabledWithJMX = !isEnabled() && shouldBeEnabled();
         if (repaired != null)
             repaired.shutdown();
         if (unrepaired != null)
             unrepaired.shutdown();
         repaired = metadata.createCompactionStrategyInstance(cfs);
         unrepaired = metadata.createCompactionStrategyInstance(cfs);
+        options = ImmutableMap.copyOf(metadata.compactionStrategyOptions);
+        if (disabledWithJMX || !shouldBeEnabled())
+            disable();
+        else
+            enable();
         startup();
     }
 
@@ -344,6 +350,28 @@ public final class WrappingCompactionStrategy extends AbstractCompactionStrategy
     }
 
     @Override
+    public void enable()
+    {
+        if (repaired != null)
+            repaired.enable();
+        if (unrepaired != null)
+            unrepaired.enable();
+        // enable this last to make sure the strategies are ready to get calls.
+        super.enable();
+    }
+
+    @Override
+    public void disable()
+    {
+        // disable this first avoid asking disabled strategies for compaction tasks
+        super.disable();
+        if (repaired != null)
+            repaired.disable();
+        if (unrepaired != null)
+            unrepaired.disable();
+    }
+
+    @Override
     public synchronized ScannerList getScanners(Collection<SSTableReader> sstables,
Range<Token> range)
     {
         List<SSTableReader> repairedSSTables = new ArrayList<>();


Mime
View raw message