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:58 UTC

[1/4] cassandra git commit: Add unit tests for enable/disable autocompaction

Repository: cassandra
Updated Branches:
  refs/heads/trunk 9acf58801 -> 7d2a96ef6


Add unit tests for enable/disable autocompaction


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

Branch: refs/heads/trunk
Commit: 1a2c1bcdc7267abec9b19d77726aedbb045d79a8
Parents: b724d1e
Author: Marcus Eriksson <ma...@apache.org>
Authored: Tue Aug 4 09:51:55 2015 +0200
Committer: Marcus Eriksson <ma...@apache.org>
Committed: Tue Aug 4 09:51:55 2015 +0200

----------------------------------------------------------------------
 .../db/compaction/CompactionsCQLTest.java       | 118 ++++++++++++++++++-
 1 file changed, 113 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/1a2c1bcd/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java b/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java
index 76e3b88..58fc062 100644
--- a/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java
@@ -21,32 +21,140 @@ import org.junit.Test;
 
 import org.apache.cassandra.cql3.CQLTester;
 import org.apache.cassandra.cql3.UntypedResultSet;
+import org.apache.cassandra.db.ColumnFamilyStore;
 import org.apache.cassandra.db.Keyspace;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 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()).getCompactionStrategy().isEnabled());
+        createTable("CREATE TABLE %s (id text PRIMARY KEY)  WITH compaction = {'class':'SizeTieredCompactionStrategy', 'min_threshold':2};");
+        assertTrue(getCurrentColumnFamilyStore().getCompactionStrategy().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());
+        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());
+        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());
+        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());
+        getCurrentColumnFamilyStore().enableAutoCompaction();
+        assertTrue(getCurrentColumnFamilyStore().getCompactionStrategy().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());
+        getCurrentColumnFamilyStore().disableAutoCompaction();
+        assertFalse(getCurrentColumnFamilyStore().getCompactionStrategy().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());
+        execute("ALTER TABLE %s WITH compaction = {'class': 'SizeTieredCompactionStrategy', 'enabled': false}");
+        assertFalse(getCurrentColumnFamilyStore().getCompactionStrategy().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());
+        execute("ALTER TABLE %s WITH compaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': 2, 'enabled': true}");
+        assertTrue(getCurrentColumnFamilyStore().getCompactionStrategy().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)
         {
-            if (r.getString("keyspace_name").equals(KEYSPACE) && r.getString("columnfamily_name").equals(currentTable()))
+            if (r.getString("keyspace_name").equals(keyspace) && r.getString("columnfamily_name").equals(cf))
                 minorWasTriggered = true;
         }
-        assertTrue(minorWasTriggered);
+        return minorWasTriggered;
     }
 }


[2/4] cassandra git commit: Merge branch 'cassandra-2.1' into cassandra-2.2

Posted by ma...@apache.org.
Merge branch 'cassandra-2.1' into cassandra-2.2


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

Branch: refs/heads/trunk
Commit: 5c59d5af751058ed86b63db05d5a17c48f4dfa41
Parents: 5a54d9a 1a2c1bc
Author: Marcus Eriksson <ma...@apache.org>
Authored: Tue Aug 4 09:52:11 2015 +0200
Committer: Marcus Eriksson <ma...@apache.org>
Committed: Tue Aug 4 09:52:11 2015 +0200

----------------------------------------------------------------------
 .../db/compaction/CompactionsCQLTest.java       | 118 ++++++++++++++++++-
 1 file changed, 113 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[4/4] cassandra git commit: Merge branch 'cassandra-3.0' into trunk

Posted by ma...@apache.org.
Merge branch 'cassandra-3.0' into trunk


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

Branch: refs/heads/trunk
Commit: 7d2a96ef67d11dae743a55954712965a7a6ae6a2
Parents: 9acf588 6932bd8
Author: Marcus Eriksson <ma...@apache.org>
Authored: Tue Aug 4 09:56:52 2015 +0200
Committer: Marcus Eriksson <ma...@apache.org>
Committed: Tue Aug 4 09:56:52 2015 +0200

----------------------------------------------------------------------
 .../db/compaction/CompactionsCQLTest.java       | 113 ++++++++++++++++++-
 1 file changed, 108 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[3/4] cassandra git commit: Merge branch 'cassandra-2.2' into cassandra-3.0

Posted by ma...@apache.org.
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/trunk
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)