cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [1/2] git commit: Followup to CASSANDRA-6916 - fix bug in cleanup and add unit test.
Date Wed, 23 Apr 2014 19:16:04 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk ec7206ce6 -> 3e6aa753e


Followup to CASSANDRA-6916 - fix bug in cleanup and add unit test.


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

Branch: refs/heads/trunk
Commit: 072b488cfcc4603d467bee6ea601c16cf92efc3e
Parents: 1f52122
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Wed Apr 23 21:09:54 2014 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Wed Apr 23 21:14:40 2014 +0200

----------------------------------------------------------------------
 .../db/compaction/CompactionManager.java        |  1 -
 .../org/apache/cassandra/db/CleanupTest.java    | 30 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/072b488c/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 8343e86..30d564c 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -675,7 +675,6 @@ public class CompactionManager implements CompactionManagerMBean
         {
             if (!hasIndexes && !new Bounds<>(sstable.first.token, sstable.last.token).intersects(ranges))
             {
-                cfs.getDataTracker().replaceReaders(Arrays.asList(sstable), Collections.<SSTableReader>emptyList());
                 cfs.getDataTracker().markCompactedSSTablesReplaced(Arrays.asList(sstable),
Collections.<SSTableReader>emptyList(), OperationType.CLEANUP);
                 continue;
             }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/072b488c/test/unit/org/apache/cassandra/db/CleanupTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/CleanupTest.java b/test/unit/org/apache/cassandra/db/CleanupTest.java
index 500f600..79a8470 100644
--- a/test/unit/org/apache/cassandra/db/CleanupTest.java
+++ b/test/unit/org/apache/cassandra/db/CleanupTest.java
@@ -21,6 +21,7 @@ package org.apache.cassandra.db;
 import static org.junit.Assert.assertEquals;
 import java.io.IOException;
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 import java.util.Arrays;
 import java.util.LinkedList;
@@ -135,6 +136,35 @@ public class CleanupTest extends SchemaLoader
         assertEquals(0, rows.size());
     }
 
+    @Test
+    public void testCleanupWithNewToken() throws ExecutionException, InterruptedException,
UnknownHostException
+    {
+        StorageService.instance.getTokenMetadata().clearUnsafe();
+
+        Keyspace keyspace = Keyspace.open(KEYSPACE1);
+        ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF2);
+
+        List<Row> rows;
+
+        // insert data and verify we get it back w/ range query
+        fillCF(cfs, LOOPS);
+
+        rows = Util.getRangeSlice(cfs);
+
+        assertEquals(LOOPS, rows.size());
+        TokenMetadata tmd = StorageService.instance.getTokenMetadata();
+
+        byte[] tk1 = new byte[1], tk2 = new byte[1];
+        tk1[0] = 2;
+        tk2[0] = 1;
+        tmd.updateNormalToken(new BytesToken(tk1), InetAddress.getByName("127.0.0.1"));
+        tmd.updateNormalToken(new BytesToken(tk2), InetAddress.getByName("127.0.0.2"));
+        CompactionManager.instance.performCleanup(cfs);
+
+        rows = Util.getRangeSlice(cfs);
+        assertEquals(0, rows.size());
+    }
+
     protected void fillCF(ColumnFamilyStore cfs, int rowsPerSSTable)
     {
         CompactionManager.instance.disableAutoCompaction();


Mime
View raw message