Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BCB3D18A52 for ; Tue, 4 Aug 2015 07:57:47 +0000 (UTC) Received: (qmail 74265 invoked by uid 500); 4 Aug 2015 07:57:47 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 74224 invoked by uid 500); 4 Aug 2015 07:57:47 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 74212 invoked by uid 99); 4 Aug 2015 07:57:47 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Aug 2015 07:57:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 659FCE1785; Tue, 4 Aug 2015 07:57:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: marcuse@apache.org To: commits@cassandra.apache.org Date: Tue, 04 Aug 2015 07:57:49 -0000 Message-Id: In-Reply-To: <5158d5070f66421283da55ff95fa96c0@git.apache.org> References: <5158d5070f66421283da55ff95fa96c0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/3] cassandra git commit: Merge branch 'cassandra-2.2' into cassandra-3.0 Merge branch 'cassandra-2.2' into cassandra-3.0 Conflicts: test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/6932bd87 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/6932bd87 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/6932bd87 Branch: refs/heads/cassandra-3.0 Commit: 6932bd879857b3b603c2d0ee284f26426b68fe6a Parents: 72f5fbd 5c59d5a Author: Marcus Eriksson Authored: Tue Aug 4 09:55:19 2015 +0200 Committer: Marcus Eriksson Committed: Tue Aug 4 09:55:19 2015 +0200 ---------------------------------------------------------------------- .../db/compaction/CompactionsCQLTest.java | 113 ++++++++++++++++++- 1 file changed, 108 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/6932bd87/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java ---------------------------------------------------------------------- diff --cc test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java index a06d4a5,58fc062..0db231e --- a/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java +++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java @@@ -27,19 -29,125 +29,120 @@@ import static org.junit.Assert.assertTr public class CompactionsCQLTest extends CQLTester { @Test - public void testTriggerMinorCompaction() throws Throwable + public void testTriggerMinorCompactionSTCS() throws Throwable { - createTable("CREATE TABLE %s (id text PRIMARY KEY);"); - assertTrue(Keyspace.open(KEYSPACE).getColumnFamilyStore(currentTable()).getCompactionStrategyManager().isEnabled()); + createTable("CREATE TABLE %s (id text PRIMARY KEY) WITH compaction = {'class':'SizeTieredCompactionStrategy', 'min_threshold':2};"); - assertTrue(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertTrue(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); execute("insert into %s (id) values ('1')"); flush(); execute("insert into %s (id) values ('1')"); flush(); + Thread.sleep(1000); + assertTrue(minorWasTriggered(KEYSPACE, currentTable())); + } + + @Test + public void testTriggerMinorCompactionLCS() throws Throwable + { + createTable("CREATE TABLE %s (id text PRIMARY KEY) WITH compaction = {'class':'LeveledCompactionStrategy', 'sstable_size_in_mb':1};"); - assertTrue(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertTrue(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); + execute("insert into %s (id) values ('1')"); + flush(); + execute("insert into %s (id) values ('1')"); + flush(); + Thread.sleep(1000); + assertTrue(minorWasTriggered(KEYSPACE, currentTable())); + } + + + @Test + public void testTriggerMinorCompactionDTCS() throws Throwable + { + createTable("CREATE TABLE %s (id text PRIMARY KEY) WITH compaction = {'class':'DateTieredCompactionStrategy', 'min_threshold':2};"); - assertTrue(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertTrue(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); + execute("insert into %s (id) values ('1')"); + flush(); + execute("insert into %s (id) values ('1')"); + flush(); + Thread.sleep(1000); + assertTrue(minorWasTriggered(KEYSPACE, currentTable())); + } + + @Test + public void testTriggerNoMinorCompactionSTCSDisabled() throws Throwable + { + createTable("CREATE TABLE %s (id text PRIMARY KEY) WITH compaction = {'class':'SizeTieredCompactionStrategy', 'min_threshold':2, 'enabled':false};"); - assertFalse(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertFalse(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); execute("insert into %s (id) values ('1')"); flush(); execute("insert into %s (id) values ('1')"); flush(); Thread.sleep(1000); + assertFalse(minorWasTriggered(KEYSPACE, currentTable())); + } + + @Test + public void testTriggerMinorCompactionSTCSNodetoolEnabled() throws Throwable + { + createTable("CREATE TABLE %s (id text PRIMARY KEY) WITH compaction = {'class':'SizeTieredCompactionStrategy', 'min_threshold':2, 'enabled':false};"); - assertFalse(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertFalse(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); + getCurrentColumnFamilyStore().enableAutoCompaction(); - assertTrue(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertTrue(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); + execute("insert into %s (id) values ('1')"); + flush(); + execute("insert into %s (id) values ('1')"); + flush(); + Thread.sleep(1000); + assertTrue(minorWasTriggered(KEYSPACE, currentTable())); + } + + @Test + public void testTriggerNoMinorCompactionSTCSNodetoolDisabled() throws Throwable + { + createTable("CREATE TABLE %s (id text PRIMARY KEY) WITH compaction = {'class':'SizeTieredCompactionStrategy', 'min_threshold':2, 'enabled':true};"); - assertTrue(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertTrue(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); + getCurrentColumnFamilyStore().disableAutoCompaction(); - assertFalse(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertFalse(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); + execute("insert into %s (id) values ('1')"); + flush(); + execute("insert into %s (id) values ('1')"); + flush(); + Thread.sleep(1000); + assertFalse(minorWasTriggered(KEYSPACE, currentTable())); + } + + @Test + public void testTriggerNoMinorCompactionSTCSAlterTable() throws Throwable + { + createTable("CREATE TABLE %s (id text PRIMARY KEY) WITH compaction = {'class':'SizeTieredCompactionStrategy', 'min_threshold':2, 'enabled':true};"); - assertTrue(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertTrue(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); + execute("ALTER TABLE %s WITH compaction = {'class': 'SizeTieredCompactionStrategy', 'enabled': false}"); - assertFalse(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertFalse(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); + execute("insert into %s (id) values ('1')"); + flush(); + execute("insert into %s (id) values ('1')"); + flush(); + Thread.sleep(1000); + assertFalse(minorWasTriggered(KEYSPACE, currentTable())); + } + + @Test + public void testTriggerMinorCompactionSTCSAlterTable() throws Throwable + { + createTable("CREATE TABLE %s (id text PRIMARY KEY) WITH compaction = {'class':'SizeTieredCompactionStrategy', 'min_threshold':2, 'enabled':false};"); - assertFalse(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertFalse(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); + execute("ALTER TABLE %s WITH compaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': 2, 'enabled': true}"); - assertTrue(getCurrentColumnFamilyStore().getCompactionStrategy().isEnabled()); ++ assertTrue(getCurrentColumnFamilyStore().getCompactionStrategyManager().isEnabled()); + execute("insert into %s (id) values ('1')"); + flush(); + execute("insert into %s (id) values ('1')"); + flush(); + Thread.sleep(1000); + assertTrue(minorWasTriggered(KEYSPACE, currentTable())); + } + - private ColumnFamilyStore getCurrentColumnFamilyStore() - { - return Keyspace.open(KEYSPACE).getColumnFamilyStore(currentTable()); - } - + public boolean minorWasTriggered(String keyspace, String cf) throws Throwable + { UntypedResultSet res = execute("SELECT * FROM system.compaction_history"); boolean minorWasTriggered = false; for (UntypedResultSet.Row r : res)