cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mish...@apache.org
Subject [1/6] git commit: Fixed handling of non-intersecting ranges in anticompaction
Date Sun, 07 Sep 2014 00:21:07 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 7d215692f -> 4f3a9c0bd
  refs/heads/cassandra-2.1.0 5d5401d67 -> 838151cab
  refs/heads/trunk bd889dc41 -> e1651cb07


Fixed handling of non-intersecting ranges in anticompaction

patch by Mikhail Stepura; reviewed by Yuki Morishita for CASSANDRA-7892


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

Branch: refs/heads/cassandra-2.1
Commit: 838151caba98f88ff583e01bad087d4ead4a764d
Parents: 5d5401d
Author: Mikhail Stepura <mishail@apache.org>
Authored: Fri Sep 5 22:44:38 2014 -0700
Committer: Mikhail Stepura <mishail@apache.org>
Committed: Sat Sep 6 17:05:27 2014 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../db/compaction/CompactionManager.java        |  1 +
 .../db/compaction/AntiCompactionTest.java       | 76 ++++++++++++++------
 3 files changed, 58 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/838151ca/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 28c39e6..ea9a05c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.0
+ * Fixed IllegalStateException in anticompaction (CASSANDRA-7892)
  * cqlsh: DESCRIBE support for frozen UDTs, tuples (CASSANDRA-7863)
  * Avoid exposing internal classes over JMX (CASSANDRA-7879)
  * Add null check for keys when freezing collection (CASSANDRA-7869)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/838151ca/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
index 09c068f..33a750b 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -430,6 +430,7 @@ public class CompactionManager implements CompactionManagerMBean
                     logger.info("SSTable {} ({}) does not intersect repaired range {}, not
touching repairedAt.", sstable, sstableRange, r);
                     nonAnticompacting.add(sstable);
                     sstableIterator.remove();
+                    break;
                 }
                 else
                 {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/838151ca/test/unit/org/apache/cassandra/db/compaction/AntiCompactionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/compaction/AntiCompactionTest.java b/test/unit/org/apache/cassandra/db/compaction/AntiCompactionTest.java
index b8637a8..6e1ac5f 100644
--- a/test/unit/org/apache/cassandra/db/compaction/AntiCompactionTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/AntiCompactionTest.java
@@ -17,12 +17,17 @@
  */
 package org.apache.cassandra.db.compaction;
 
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
-import org.junit.Test;
 
 import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
@@ -37,9 +42,10 @@ import org.apache.cassandra.io.sstable.SSTableIdentityIterator;
 import org.apache.cassandra.io.sstable.SSTableReader;
 import org.apache.cassandra.io.sstable.SSTableScanner;
 import org.apache.cassandra.utils.ByteBufferUtil;
-import static junit.framework.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.junit.After;
+import org.junit.Test;
+
+import com.google.common.collect.Iterables;
 
 public class AntiCompactionTest extends SchemaLoader
 {
@@ -49,22 +55,7 @@ public class AntiCompactionTest extends SchemaLoader
     @Test
     public void antiCompactOne() throws InterruptedException, ExecutionException, IOException
     {
-        Keyspace keyspace = Keyspace.open(KEYSPACE1);
-        ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
-        store.disableAutoCompaction();
-        long timestamp = System.currentTimeMillis();
-        for (int i = 0; i < 10; i++)
-        {
-            DecoratedKey key = Util.dk(Integer.toString(i));
-            Mutation rm = new Mutation(KEYSPACE1, key.getKey());
-            for (int j = 0; j < 10; j++)
-                rm.add("Standard1", Util.cellname(Integer.toString(j)),
-                       ByteBufferUtil.EMPTY_BYTE_BUFFER,
-                       timestamp,
-                       0);
-            rm.apply();
-        }
-        store.forceBlockingFlush();
+        ColumnFamilyStore store = prepareColumnFamilyStore();
         Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
         assertEquals(store.getSSTables().size(), sstables.size());
         Range<Token> range = new Range<Token>(new BytesToken("0".getBytes()),
new BytesToken("4".getBytes()));
@@ -98,4 +89,49 @@ public class AntiCompactionTest extends SchemaLoader
         assertEquals(repairedKeys, 4);
         assertEquals(nonRepairedKeys, 6);
     }
+    
+    @Test
+    public void shouldSkipAntiCompactionForNonIntersectingRange() throws InterruptedException,
ExecutionException, IOException
+    {
+        ColumnFamilyStore store = prepareColumnFamilyStore();
+        Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
+        assertEquals(store.getSSTables().size(), sstables.size());
+        Range<Token> range = new Range<Token>(new BytesToken("-10".getBytes()),
new BytesToken("-1".getBytes()));
+        List<Range<Token>> ranges = Arrays.asList(range);
+
+        SSTableReader.acquireReferences(sstables);
+        CompactionManager.instance.performAnticompaction(store, ranges, sstables, 0);
+
+        assertThat(store.getSSTables().size(), is(1));
+        assertThat(Iterables.get(store.getSSTables(), 0).isRepaired(), is(false));
+    }
+
+    private ColumnFamilyStore prepareColumnFamilyStore()
+    {
+        Keyspace keyspace = Keyspace.open(KEYSPACE1);
+        ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
+        store.disableAutoCompaction();
+        long timestamp = System.currentTimeMillis();
+        for (int i = 0; i < 10; i++)
+        {
+            DecoratedKey key = Util.dk(Integer.toString(i));
+            Mutation rm = new Mutation(KEYSPACE1, key.getKey());
+            for (int j = 0; j < 10; j++)
+                rm.add("Standard1", Util.cellname(Integer.toString(j)),
+                       ByteBufferUtil.EMPTY_BYTE_BUFFER,
+                       timestamp,
+                       0);
+            rm.apply();
+        }
+        store.forceBlockingFlush();
+        return store;
+    }
+    
+    @After
+    public void truncateCF()
+    {
+        Keyspace keyspace = Keyspace.open(KEYSPACE1);
+        ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF);
+        store.truncateBlocking();
+    }
 }


Mime
View raw message