cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [1/2] cassandra git commit: Fix LongLeveledCompactionStrategyTest
Date Tue, 12 May 2015 06:23:52 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 894b7b9a7 -> cf6f7c163


Fix LongLeveledCompactionStrategyTest

Patch by Stefania; reviewed by marcuse for CASSANDRA-9288


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

Branch: refs/heads/trunk
Commit: ed0026fed868dff61601a073b649ed8b9d5e6311
Parents: ac70e37
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Tue May 12 10:39:48 2015 +0800
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Tue May 12 08:16:02 2015 +0200

----------------------------------------------------------------------
 .../LongLeveledCompactionStrategyTest.java      | 38 ++++++++++++--------
 1 file changed, 23 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ed0026fe/test/long/org/apache/cassandra/db/compaction/LongLeveledCompactionStrategyTest.java
----------------------------------------------------------------------
diff --git a/test/long/org/apache/cassandra/db/compaction/LongLeveledCompactionStrategyTest.java
b/test/long/org/apache/cassandra/db/compaction/LongLeveledCompactionStrategyTest.java
index b071001..0eb769f 100644
--- a/test/long/org/apache/cassandra/db/compaction/LongLeveledCompactionStrategyTest.java
+++ b/test/long/org/apache/cassandra/db/compaction/LongLeveledCompactionStrategyTest.java
@@ -31,6 +31,8 @@ import org.apache.cassandra.db.*;
 import org.apache.cassandra.io.sstable.SSTableReader;
 import org.apache.cassandra.utils.FBUtilities;
 
+import static org.junit.Assert.assertTrue;
+
 public class LongLeveledCompactionStrategyTest extends SchemaLoader
 {
     @Test
@@ -42,7 +44,8 @@ public class LongLeveledCompactionStrategyTest extends SchemaLoader
         ColumnFamilyStore store = keyspace.getColumnFamilyStore(cfname);
         store.disableAutoCompaction();
 
-        LeveledCompactionStrategy lcs = (LeveledCompactionStrategy)store.getCompactionStrategy();
+        WrappingCompactionStrategy strategy = ((WrappingCompactionStrategy) store.getCompactionStrategy());
+        LeveledCompactionStrategy lcs = (LeveledCompactionStrategy) strategy.getWrappedStrategies().get(1);
 
         ByteBuffer value = ByteBuffer.wrap(new byte[100 * 1024]); // 100 KB value, make it
easy to have multiple files
 
@@ -63,26 +66,30 @@ public class LongLeveledCompactionStrategyTest extends SchemaLoader
             store.forceBlockingFlush();
         }
 
+
         // Execute LCS in parallel
         ExecutorService executor = new ThreadPoolExecutor(4, 4,
                                                           Long.MAX_VALUE, TimeUnit.SECONDS,
                                                           new LinkedBlockingDeque<Runnable>());
+
         List<Runnable> tasks = new ArrayList<Runnable>();
         while (true)
         {
             while (true)
             {
-                final AbstractCompactionTask t = lcs.getMaximalTask(Integer.MIN_VALUE).iterator().next();
-                if (t == null)
+                final AbstractCompactionTask nextTask = lcs.getNextBackgroundTask(Integer.MIN_VALUE);
+                if (nextTask == null)
                     break;
+
                 tasks.add(new Runnable()
                 {
                     public void run()
                     {
-                        t.execute(null);
+                        nextTask.execute(null);
                     }
                 });
             }
+
             if (tasks.isEmpty())
                 break;
 
@@ -94,27 +101,28 @@ public class LongLeveledCompactionStrategyTest extends SchemaLoader
             tasks.clear();
         }
 
+
         // Assert all SSTables are lined up correctly.
         LeveledManifest manifest = lcs.manifest;
         int levels = manifest.getLevelCount();
         for (int level = 0; level < levels; level++)
         {
             List<SSTableReader> sstables = manifest.getLevel(level);
+
             // score check
             assert (double) SSTableReader.getTotalBytes(sstables) / manifest.maxBytesForLevel(level)
< 1.00;
-            // overlap check for levels greater than 0
-            if (level > 0)
+
+            for (SSTableReader sstable : sstables)
             {
-               for (SSTableReader sstable : sstables)
-               {
-                   Set<SSTableReader> overlaps = LeveledManifest.overlapping(sstable,
sstables);
-                   assert overlaps.size() == 1 && overlaps.contains(sstable);
-               }
+                // level check
+                assert level == sstable.getSSTableLevel();
+
+                if (level > 0)
+                {// overlap check for levels greater than 0
+                    Set<SSTableReader> overlaps = LeveledManifest.overlapping(sstable,
sstables);
+                    assert overlaps.size() == 1 && overlaps.contains(sstable);
+                }
             }
         }
-        for (SSTableReader sstable : store.getSSTables())
-        {
-            assert sstable.getSSTableLevel() == sstable.getSSTableLevel();
-        }
     }
 }


Mime
View raw message