You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ma...@apache.org on 2015/08/04 09:57:49 UTC

[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 <ma...@apache.org>
Authored: Tue Aug 4 09:55:19 2015 +0200
Committer: Marcus Eriksson <ma...@apache.org>
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)