cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [1/3] git commit: Make sure we keep the sstable level when running upgradesstables.
Date Tue, 01 Apr 2014 05:45:15 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 3b1423945 -> 5cdfa69ca


Make sure we keep the sstable level when running upgradesstables.

Patch by marcuse; reviewed by yukim for CASSANDRA-6958


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

Branch: refs/heads/trunk
Commit: a90b98e902fc54f62a379a6ce1e6ddead43ba1ec
Parents: 0fce7ac
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Tue Apr 1 07:37:12 2014 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Tue Apr 1 07:40:35 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                         |  1 +
 .../db/compaction/AbstractCompactionStrategy.java   |  2 ++
 .../cassandra/db/compaction/CompactionManager.java  |  2 +-
 .../db/compaction/LeveledCompactionStrategy.java    | 16 ++++++++++++++++
 .../db/compaction/SizeTieredCompactionStrategy.java |  6 ++++++
 .../apache/cassandra/db/compaction/Upgrader.java    |  2 ++
 6 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a90b98e9/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b4f84e4..3326c6c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -36,6 +36,7 @@
  * Add CqlRecordReader using native pagination (CASSANDRA-6311)
  * Add QueryHandler interface (CASSANDRA-6659)
  * Track liveRatio per-memtable, not per-CF (CASSANDRA-6945)
+ * Make sure upgradesstables keeps sstable level (CASSANDRA-6958)
 Merged from 1.2:
  * Add UNLOGGED, COUNTER options to BATCH documentation (CASSANDRA-6816)
  * add extra SSL cipher suites (CASSANDRA-6613)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a90b98e9/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 5425683..d3339d5 100644
--- a/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
@@ -167,6 +167,8 @@ public abstract class AbstractCompactionStrategy
      */
     public abstract AbstractCompactionTask getUserDefinedTask(Collection<SSTableReader>
sstables, final int gcBefore);
 
+    public abstract AbstractCompactionTask getCompactionTask(Collection<SSTableReader>
sstables, final int gcBefore, long maxSSTableBytes);
+
     /**
      * @return the number of background tasks estimated to still be needed for this columnfamilystore
      */

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a90b98e9/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 453176e..31b7d8e 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -251,7 +251,7 @@ public class CompactionManager implements CompactionManagerMBean
 
                     // SSTables are marked by the caller
                     // NOTE: it is important that the task create one and only one sstable,
even for Leveled compaction (see LeveledManifest.replace())
-                    CompactionTask task = new CompactionTask(cfs, Collections.singletonList(sstable),
NO_GC);
+                    AbstractCompactionTask task = cfs.getCompactionStrategy().getCompactionTask(Collections.singleton(sstable),
NO_GC, Long.MAX_VALUE);
                     task.setUserDefined(true);
                     task.setCompactionType(OperationType.UPGRADE_SSTABLES);
                     task.execute(metrics);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a90b98e9/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 18b9fbd..8637a2e 100644
--- a/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
@@ -152,6 +152,22 @@ public class LeveledCompactionStrategy extends AbstractCompactionStrategy
implem
         throw new UnsupportedOperationException("LevelDB compaction strategy does not allow
user-specified compactions");
     }
 
+    @Override
+    public AbstractCompactionTask getCompactionTask(Collection<SSTableReader> sstables,
int gcBefore, long maxSSTableBytes)
+    {
+        assert sstables.size() > 0;
+        int level = -1;
+        // if all sstables are in the same level, we can set that level:
+        for (SSTableReader sstable : sstables)
+        {
+            if (level == -1)
+                level = sstable.getSSTableLevel();
+            if (level != sstable.getSSTableLevel())
+                level = 0;
+        }
+        return new LeveledCompactionTask(cfs, sstables, level, gcBefore, maxSSTableBytes);
+    }
+
     public int getEstimatedRemainingTasks()
     {
         return manifest.getEstimatedTasks();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a90b98e9/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 0f94918..fae52e2 100644
--- a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
@@ -271,6 +271,12 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
         return new CompactionTask(cfs, sstables, gcBefore).setUserDefined(true);
     }
 
+    @Override
+    public AbstractCompactionTask getCompactionTask(Collection<SSTableReader> sstables,
int gcBefore, long maxSSTableBytes)
+    {
+        return new CompactionTask(cfs, sstables, gcBefore);
+    }
+
     public int getEstimatedRemainingTasks()
     {
         return estimatedRemainingTasks;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a90b98e9/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 2805a52..98a55e9 100644
--- a/src/java/org/apache/cassandra/db/compaction/Upgrader.java
+++ b/src/java/org/apache/cassandra/db/compaction/Upgrader.java
@@ -66,6 +66,7 @@ public class Upgrader
 
         // Get the max timestamp of the precompacted sstables
         // and adds generation of live ancestors
+        // -- note that we always only have one SSTable in toUpgrade here:
         for (SSTableReader sstable : toUpgrade)
         {
             sstableMetadataCollector.addAncestor(sstable.descriptor.generation);
@@ -74,6 +75,7 @@ public class Upgrader
                 if (new File(sstable.descriptor.withGeneration(i).filenameFor(Component.DATA)).exists())
                     sstableMetadataCollector.addAncestor(i);
             }
+            sstableMetadataCollector.sstableLevel(sstable.getSSTableLevel());
         }
 
         return new SSTableWriter(cfs.getTempSSTablePath(directory), estimatedRows, cfs.metadata,
cfs.partitioner, sstableMetadataCollector);


Mime
View raw message