Merge branch 'cassandra-2.2' into cassandra-3.0
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/fdd2cd0a Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/fdd2cd0a Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/fdd2cd0a Branch: refs/heads/cassandra-3.0 Commit: fdd2cd0a90c5c087c5f3194362eeff57a351a539 Parents: d436407 b59da28 Author: Marcus Eriksson <marc...@apache.org> Authored: Thu Feb 11 08:48:43 2016 +0100 Committer: Marcus Eriksson <marc...@apache.org> Committed: Thu Feb 11 08:48:43 2016 +0100 ---------------------------------------------------------------------- .../LeveledCompactionStrategyTest.java | 28 +++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/fdd2cd0a/test/unit/org/apache/cassandra/db/compaction/LeveledCompactionStrategyTest.java ---------------------------------------------------------------------- diff --cc test/unit/org/apache/cassandra/db/compaction/LeveledCompactionStrategyTest.java index f2ddb00,1b6d58c..77d2d12 --- a/test/unit/org/apache/cassandra/db/compaction/LeveledCompactionStrategyTest.java +++ b/test/unit/org/apache/cassandra/db/compaction/LeveledCompactionStrategyTest.java @@@ -196,13 -209,29 +196,29 @@@ public class LeveledCompactionStrategyT */ private void waitForLeveling(ColumnFamilyStore cfs) throws InterruptedException { - CompactionStrategyManager strategy = cfs.getCompactionStrategyManager(); - // L0 is the lowest priority, so when that's done, we know everything is done - while (strategy.getSSTableCountPerLevel()[0] > 1) - WrappingCompactionStrategy strategyManager = (WrappingCompactionStrategy)cfs.getCompactionStrategy(); ++ CompactionStrategyManager strategyManager = cfs.getCompactionStrategyManager(); + while (true) + { + // since we run several compaction strategies we wait until L0 in all strategies is empty and + // atleast one L1+ is non-empty. In these tests we always run a single data directory with only unrepaired data + // so it should be good enough + boolean allL0Empty = true; + boolean anyL1NonEmpty = false; - for (AbstractCompactionStrategy strategy : strategyManager.getWrappedStrategies()) ++ for (AbstractCompactionStrategy strategy : strategyManager.getStrategies()) + { + if (!(strategy instanceof LeveledCompactionStrategy)) + return; + // note that we check > 1 here, if there is too little data in L0, we don't compact it up to L1 + if (((LeveledCompactionStrategy)strategy).getLevelSize(0) > 1) + allL0Empty = false; + for (int i = 1; i < 5; i++) + if (((LeveledCompactionStrategy)strategy).getLevelSize(i) > 0) + anyL1NonEmpty = true; + } + if (allL0Empty && anyL1NonEmpty) + return; Thread.sleep(100); - - // in AbstractCompationStrategy.replaceSSTables() first we remove and then we add sstables so wait a little bit longer - Thread.sleep(10); + } } @Test