cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject cassandra git commit: Avoid having compactions disabled on new tables
Date Mon, 03 Aug 2015 19:35:04 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 5c58af97a -> b724d1ea5


Avoid having compactions disabled on new tables

Patch by marcuse; reviewed by Jeremiah Jordan for CASSANDRA-9963


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

Branch: refs/heads/cassandra-2.1
Commit: b724d1ea5139140935b56fd8397d85419ed85408
Parents: 5c58af9
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Mon Aug 3 17:56:52 2015 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Mon Aug 3 21:30:42 2015 +0200

----------------------------------------------------------------------
 .../compaction/WrappingCompactionStrategy.java  |  2 +-
 .../db/compaction/CompactionsCQLTest.java       | 52 ++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b724d1ea/src/java/org/apache/cassandra/db/compaction/WrappingCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/WrappingCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/WrappingCompactionStrategy.java
index e01b4c6..0fed733 100644
--- a/src/java/org/apache/cassandra/db/compaction/WrappingCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/WrappingCompactionStrategy.java
@@ -156,7 +156,7 @@ public final class WrappingCompactionStrategy extends AbstractCompactionStrategy
 
     public synchronized void reloadCompactionStrategy(CFMetaData metadata)
     {
-        boolean disabledWithJMX = !isEnabled() && shouldBeEnabled();
+        boolean disabledWithJMX = !enabled && shouldBeEnabled();
         if (repaired != null)
             repaired.shutdown();
         if (unrepaired != null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b724d1ea/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
new file mode 100644
index 0000000..76e3b88
--- /dev/null
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsCQLTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cassandra.db.compaction;
+
+import org.junit.Test;
+
+import org.apache.cassandra.cql3.CQLTester;
+import org.apache.cassandra.cql3.UntypedResultSet;
+import org.apache.cassandra.db.Keyspace;
+import static org.junit.Assert.assertTrue;
+
+public class CompactionsCQLTest extends CQLTester
+{
+    @Test
+    public void testTriggerMinorCompaction() throws Throwable
+    {
+        createTable("CREATE TABLE %s (id text PRIMARY KEY);");
+        assertTrue(Keyspace.open(KEYSPACE).getColumnFamilyStore(currentTable()).getCompactionStrategy().isEnabled());
+        execute("insert into %s (id) values ('1')");
+        flush();
+        execute("insert into %s (id) values ('1')");
+        flush();
+        execute("insert into %s (id) values ('1')");
+        flush();
+        execute("insert into %s (id) values ('1')");
+        flush();
+        Thread.sleep(1000);
+        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()))
+                minorWasTriggered = true;
+        }
+        assertTrue(minorWasTriggered);
+    }
+}


Mime
View raw message