You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by be...@apache.org on 2015/06/03 14:10:16 UTC
[1/9] cassandra git commit: Ensure truncate without snapshot cannot
return corrupt responses
Repository: cassandra
Updated Branches:
refs/heads/cassandra-2.2 08a5dab00 -> 99da21022
refs/heads/trunk e8fd1b1f4 -> 304eae3b7
Ensure truncate without snapshot cannot return corrupt responses
patch by benedict; reviewed by aleksey for CASSANDRA-9388
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/62500650
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/62500650
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/62500650
Branch: refs/heads/cassandra-2.2
Commit: 6250065089b80d02d54908212d2b5f45037720f2
Parents: 40c3ad6
Author: Benedict Elliott Smith <be...@apache.org>
Authored: Tue Jun 2 18:11:45 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Tue Jun 2 18:11:45 2015 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../apache/cassandra/db/ColumnFamilyStore.java | 32 +++++++++++---------
2 files changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/62500650/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 75eb752..9ce5680 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.1.6
+ * Ensure truncate without snapshot cannot produce corrupt responses (CASSANDRA-9388)
* Consistent error message when a table mixes counter and non-counter
columns (CASSANDRA-9492)
* Avoid getting unreadable keys during anticompaction (CASSANDRA-9508)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/62500650/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 5f47476..d686e67 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1078,7 +1078,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
if (memtable.isClean() || truncate)
{
memtable.cfs.replaceFlushed(memtable, null);
- memtable.setDiscarded();
+ reclaim(memtable);
iter.remove();
}
}
@@ -1091,27 +1091,31 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
metric.memtableSwitchCount.inc();
- for (final Memtable memtable : memtables)
+ for (Memtable memtable : memtables)
{
// flush the memtable
MoreExecutors.sameThreadExecutor().execute(memtable.flushRunnable());
-
- // issue a read barrier for reclaiming the memory, and offload the wait to another thread
- final OpOrder.Barrier readBarrier = readOrdering.newBarrier();
- readBarrier.issue();
- reclaimExecutor.execute(new WrappedRunnable()
- {
- public void runMayThrow() throws InterruptedException, ExecutionException
- {
- readBarrier.await();
- memtable.setDiscarded();
- }
- });
+ reclaim(memtable);
}
// signal the post-flush we've done our work
postFlush.latch.countDown();
}
+
+ private void reclaim(final Memtable memtable)
+ {
+ // issue a read barrier for reclaiming the memory, and offload the wait to another thread
+ final OpOrder.Barrier readBarrier = readOrdering.newBarrier();
+ readBarrier.issue();
+ reclaimExecutor.execute(new WrappedRunnable()
+ {
+ public void runMayThrow() throws InterruptedException, ExecutionException
+ {
+ readBarrier.await();
+ memtable.setDiscarded();
+ }
+ });
+ }
}
/**
[2/9] cassandra git commit: Ensure truncate without snapshot cannot
return corrupt responses
Posted by be...@apache.org.
Ensure truncate without snapshot cannot return corrupt responses
patch by benedict; reviewed by aleksey for CASSANDRA-9388
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/62500650
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/62500650
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/62500650
Branch: refs/heads/trunk
Commit: 6250065089b80d02d54908212d2b5f45037720f2
Parents: 40c3ad6
Author: Benedict Elliott Smith <be...@apache.org>
Authored: Tue Jun 2 18:11:45 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Tue Jun 2 18:11:45 2015 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../apache/cassandra/db/ColumnFamilyStore.java | 32 +++++++++++---------
2 files changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/62500650/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 75eb752..9ce5680 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
2.1.6
+ * Ensure truncate without snapshot cannot produce corrupt responses (CASSANDRA-9388)
* Consistent error message when a table mixes counter and non-counter
columns (CASSANDRA-9492)
* Avoid getting unreadable keys during anticompaction (CASSANDRA-9508)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/62500650/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 5f47476..d686e67 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1078,7 +1078,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
if (memtable.isClean() || truncate)
{
memtable.cfs.replaceFlushed(memtable, null);
- memtable.setDiscarded();
+ reclaim(memtable);
iter.remove();
}
}
@@ -1091,27 +1091,31 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
metric.memtableSwitchCount.inc();
- for (final Memtable memtable : memtables)
+ for (Memtable memtable : memtables)
{
// flush the memtable
MoreExecutors.sameThreadExecutor().execute(memtable.flushRunnable());
-
- // issue a read barrier for reclaiming the memory, and offload the wait to another thread
- final OpOrder.Barrier readBarrier = readOrdering.newBarrier();
- readBarrier.issue();
- reclaimExecutor.execute(new WrappedRunnable()
- {
- public void runMayThrow() throws InterruptedException, ExecutionException
- {
- readBarrier.await();
- memtable.setDiscarded();
- }
- });
+ reclaim(memtable);
}
// signal the post-flush we've done our work
postFlush.latch.countDown();
}
+
+ private void reclaim(final Memtable memtable)
+ {
+ // issue a read barrier for reclaiming the memory, and offload the wait to another thread
+ final OpOrder.Barrier readBarrier = readOrdering.newBarrier();
+ readBarrier.issue();
+ reclaimExecutor.execute(new WrappedRunnable()
+ {
+ public void runMayThrow() throws InterruptedException, ExecutionException
+ {
+ readBarrier.await();
+ memtable.setDiscarded();
+ }
+ });
+ }
}
/**
[7/9] cassandra git commit: Do not reuse cfs in MockSchema
Posted by be...@apache.org.
Do not reuse cfs in MockSchema
patch by stefania; reviewed by benedict for CASSANDRA-9537
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/99da2102
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/99da2102
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/99da2102
Branch: refs/heads/cassandra-2.2
Commit: 99da210229b9ddab8ce46d0664c46fe92282c6e3
Parents: c1c7855
Author: stefania <st...@datastax.com>
Authored: Wed Jun 3 13:07:21 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Wed Jun 3 13:07:21 2015 +0100
----------------------------------------------------------------------
test/unit/org/apache/cassandra/MockSchema.java | 21 +++-----
.../cassandra/db/lifecycle/HelpersTest.java | 7 ++-
.../db/lifecycle/LifecycleTransactionTest.java | 52 ++++++++++++--------
.../cassandra/db/lifecycle/TrackerTest.java | 24 ++++++---
.../apache/cassandra/db/lifecycle/ViewTest.java | 24 +++++----
5 files changed, 74 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99da2102/test/unit/org/apache/cassandra/MockSchema.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/MockSchema.java b/test/unit/org/apache/cassandra/MockSchema.java
index 86593c2..94313cd 100644
--- a/test/unit/org/apache/cassandra/MockSchema.java
+++ b/test/unit/org/apache/cassandra/MockSchema.java
@@ -62,38 +62,33 @@ public class MockSchema
}
private static final AtomicInteger id = new AtomicInteger();
public static final Keyspace ks = Keyspace.mockKS(new KSMetaData("mockks", SimpleStrategy.class, ImmutableMap.of("replication_factor", "1"), false));
- public static final ColumnFamilyStore cfs = newCFS();
private static final IndexSummary indexSummary;
private static final SegmentedFile segmentedFile = new BufferedSegmentedFile(new ChannelProxy(temp("mocksegmentedfile")), 0);
- public static Memtable memtable()
+ public static Memtable memtable(ColumnFamilyStore cfs)
{
return new Memtable(cfs.metadata);
}
- public static SSTableReader sstable(int generation)
+ public static SSTableReader sstable(int generation, ColumnFamilyStore cfs)
{
- return sstable(generation, false);
+ return sstable(generation, false, cfs);
}
- public static SSTableReader sstable(int generation, boolean keepRef)
+ public static SSTableReader sstable(int generation, boolean keepRef, ColumnFamilyStore cfs)
{
- return sstable(generation, 0, keepRef);
+ return sstable(generation, 0, keepRef, cfs);
}
- public static SSTableReader sstable(int generation, int size)
+ public static SSTableReader sstable(int generation, int size, ColumnFamilyStore cfs)
{
- return sstable(generation, size, false);
+ return sstable(generation, size, false, cfs);
}
- public static SSTableReader sstable(int generation, int size, boolean keepRef)
- {
- return sstable(generation, size, keepRef, cfs);
- }
public static SSTableReader sstable(int generation, int size, boolean keepRef, ColumnFamilyStore cfs)
{
- Descriptor descriptor = new Descriptor(temp("mockcfdir").getParentFile(), "mockks", "mockcf", generation, Descriptor.Type.FINAL);
+ Descriptor descriptor = new Descriptor(temp("mockcfdir").getParentFile(), ks.getName(), cfs.getColumnFamilyName(), generation, Descriptor.Type.FINAL);
Set<Component> components = ImmutableSet.of(Component.DATA, Component.PRIMARY_INDEX, Component.FILTER, Component.TOC);
for (Component component : components)
{
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99da2102/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java b/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
index d53a830..24d2bda 100644
--- a/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
+++ b/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
@@ -30,6 +30,7 @@ import org.junit.Test;
import junit.framework.Assert;
import org.apache.cassandra.MockSchema;
import org.apache.cassandra.Util;
+import org.apache.cassandra.db.ColumnFamilyStore;
import org.apache.cassandra.io.sstable.Descriptor;
import org.apache.cassandra.io.sstable.format.SSTableReader;
import org.apache.cassandra.io.sstable.format.big.BigTableReader;
@@ -135,7 +136,8 @@ public class HelpersTest
@Test
public void testSetupDeletionNotification()
{
- Iterable<SSTableReader> readers = Lists.newArrayList(MockSchema.sstable(1), MockSchema.sstable(2));
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ Iterable<SSTableReader> readers = Lists.newArrayList(MockSchema.sstable(1, cfs), MockSchema.sstable(2, cfs));
Throwable accumulate = Helpers.setReplaced(readers, null);
Assert.assertNull(accumulate);
for (SSTableReader reader : readers)
@@ -147,7 +149,8 @@ public class HelpersTest
@Test
public void testMarkObsolete()
{
- Iterable<SSTableReader> readers = Lists.newArrayList(MockSchema.sstable(1), MockSchema.sstable(2));
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ Iterable<SSTableReader> readers = Lists.newArrayList(MockSchema.sstable(1, cfs), MockSchema.sstable(2, cfs));
Throwable accumulate = Helpers.markObsolete(readers, null);
Assert.assertNull(accumulate);
for (SSTableReader reader : readers)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99da2102/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java b/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
index 3153ef1..2c6c830 100644
--- a/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
+++ b/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
@@ -28,11 +28,13 @@ import org.junit.Test;
import junit.framework.Assert;
import org.apache.cassandra.MockSchema;
import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.db.ColumnFamilyStore;
import org.apache.cassandra.db.compaction.OperationType;
import org.apache.cassandra.db.lifecycle.LifecycleTransaction.ReaderState;
import org.apache.cassandra.db.lifecycle.LifecycleTransaction.ReaderState.Action;
import org.apache.cassandra.io.sstable.SSTableDeletingTask;
import org.apache.cassandra.io.sstable.format.SSTableReader;
+import org.apache.cassandra.metrics.ColumnFamilyMetrics;
import org.apache.cassandra.utils.Pair;
import org.apache.cassandra.utils.concurrent.AbstractTransactionalTest;
import org.apache.cassandra.utils.concurrent.Transactional.AbstractTransactional.State;
@@ -66,10 +68,11 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
@Test
public void testUpdates() // (including obsoletion)
{
+ ColumnFamilyStore cfs = MockSchema.newCFS();
Tracker tracker = new Tracker(null, false);
- SSTableReader[] readers = readersArray(0, 3);
- SSTableReader[] readers2 = readersArray(0, 4);
- SSTableReader[] readers3 = readersArray(0, 4);
+ SSTableReader[] readers = readersArray(0, 3, cfs);
+ SSTableReader[] readers2 = readersArray(0, 4, cfs);
+ SSTableReader[] readers3 = readersArray(0, 4, cfs);
tracker.addInitialSSTables(copyOf(readers));
LifecycleTransaction txn = tracker.tryModify(copyOf(readers), OperationType.UNKNOWN);
@@ -129,15 +132,16 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
@Test
public void testCancellation()
{
+ ColumnFamilyStore cfs = MockSchema.newCFS();
Tracker tracker = new Tracker(null, false);
- List<SSTableReader> readers = readers(0, 3);
+ List<SSTableReader> readers = readers(0, 3, cfs);
tracker.addInitialSSTables(readers);
LifecycleTransaction txn = tracker.tryModify(readers, OperationType.UNKNOWN);
SSTableReader cancel = readers.get(0);
- SSTableReader update = readers(1, 2).get(0);
- SSTableReader fresh = readers(3, 4).get(0);
- SSTableReader notPresent = readers(4, 5).get(0);
+ SSTableReader update = readers(1, 2, cfs).get(0);
+ SSTableReader fresh = readers(3, 4,cfs).get(0);
+ SSTableReader notPresent = readers(4, 5, cfs).get(0);
txn.cancel(cancel);
txn.update(update, true);
@@ -172,8 +176,9 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
@Test
public void testSplit()
{
+ ColumnFamilyStore cfs = MockSchema.newCFS();
Tracker tracker = new Tracker(null, false);
- List<SSTableReader> readers = readers(0, 3);
+ List<SSTableReader> readers = readers(0, 3, cfs);
tracker.addInitialSSTables(readers);
LifecycleTransaction txn = tracker.tryModify(readers, OperationType.UNKNOWN);
LifecycleTransaction txn2 = txn.split(readers.subList(0, 1));
@@ -181,7 +186,7 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
Assert.assertTrue(all(readers.subList(1, 3), in(txn.originals())));
Assert.assertEquals(1, txn2.originals().size());
Assert.assertTrue(all(readers.subList(0, 1), in(txn2.originals())));
- txn.update(readers(1, 2).get(0), true);
+ txn.update(readers(1, 2, cfs).get(0), true);
boolean failed = false;
try
{
@@ -255,21 +260,26 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
final Tracker tracker;
final LifecycleTransaction txn;
- private static Tracker tracker(List<SSTableReader> readers)
+ private static Tracker tracker(ColumnFamilyStore cfs, List<SSTableReader> readers)
{
- Tracker tracker = new Tracker(MockSchema.cfs, false);
+ Tracker tracker = new Tracker(cfs, false);
tracker.addInitialSSTables(readers);
return tracker;
}
private TxnTest()
{
- this(readers(0, 8));
+ this(MockSchema.newCFS());
}
- private TxnTest(List<SSTableReader> readers)
+ private TxnTest(ColumnFamilyStore cfs)
{
- this(tracker(readers), readers);
+ this(cfs, readers(0, 8, cfs));
+ }
+
+ private TxnTest(ColumnFamilyStore cfs, List<SSTableReader> readers)
+ {
+ this(tracker(cfs, readers), readers);
}
private TxnTest(Tracker tracker, List<SSTableReader> readers)
@@ -283,11 +293,11 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
this.tracker = tracker;
this.originals = readers;
this.txn = txn;
- update(txn, loggedUpdate = readers(0, 2), true);
+ update(txn, loggedUpdate = readers(0, 2, tracker.cfstore), true);
obsolete(txn, loggedObsolete = readers.subList(2, 4));
- update(txn, loggedNew = readers(8, 10), false);
+ update(txn, loggedNew = readers(8, 10, tracker.cfstore), false);
txn.checkpoint();
- update(txn, stagedNew = readers(10, 12), false);
+ update(txn, stagedNew = readers(10, 12, tracker.cfstore), false);
obsolete(txn, stagedObsolete = copyOf(concat(loggedUpdate, originals.subList(4, 6))));
untouchedOriginals = originals.subList(6, 8);
}
@@ -385,16 +395,16 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
}
}
- private static SSTableReader[] readersArray(int lb, int ub)
+ private static SSTableReader[] readersArray(int lb, int ub, ColumnFamilyStore cfs)
{
- return readers(lb, ub).toArray(new SSTableReader[0]);
+ return readers(lb, ub, cfs).toArray(new SSTableReader[0]);
}
- private static List<SSTableReader> readers(int lb, int ub)
+ private static List<SSTableReader> readers(int lb, int ub, ColumnFamilyStore cfs)
{
List<SSTableReader> readers = new ArrayList<>();
for (int i = lb ; i < ub ; i++)
- readers.add(MockSchema.sstable(i, i, true));
+ readers.add(MockSchema.sstable(i, i, true, cfs));
return copyOf(readers);
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99da2102/test/unit/org/apache/cassandra/db/lifecycle/TrackerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/lifecycle/TrackerTest.java b/test/unit/org/apache/cassandra/db/lifecycle/TrackerTest.java
index 1859e70..0d46153 100644
--- a/test/unit/org/apache/cassandra/db/lifecycle/TrackerTest.java
+++ b/test/unit/org/apache/cassandra/db/lifecycle/TrackerTest.java
@@ -82,7 +82,7 @@ public class TrackerTest
{
ColumnFamilyStore cfs = MockSchema.newCFS();
Tracker tracker = new Tracker(cfs, false);
- List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0), MockSchema.sstable(1), MockSchema.sstable(2));
+ List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, cfs), MockSchema.sstable(1, cfs), MockSchema.sstable(2, cfs));
tracker.addInitialSSTables(copyOf(readers));
try (LifecycleTransaction txn = tracker.tryModify(readers.get(0), OperationType.COMPACTION);)
{
@@ -101,8 +101,9 @@ public class TrackerTest
@Test
public void testApply()
{
+ final ColumnFamilyStore cfs = MockSchema.newCFS();
final Tracker tracker = new Tracker(null, false);
- final View resultView = ViewTest.fakeView(0, 0);
+ final View resultView = ViewTest.fakeView(0, 0, cfs);
final AtomicInteger count = new AtomicInteger();
tracker.apply(new Predicate<View>()
{
@@ -110,7 +111,7 @@ public class TrackerTest
{
// confound the CAS by swapping the view, and check we retry
if (count.incrementAndGet() < 3)
- tracker.view.set(ViewTest.fakeView(0, 0));
+ tracker.view.set(ViewTest.fakeView(0, 0, cfs));
return true;
}
}, new Function<View, View>()
@@ -143,7 +144,9 @@ public class TrackerTest
{
ColumnFamilyStore cfs = MockSchema.newCFS();
Tracker tracker = new Tracker(cfs, false);
- List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 17), MockSchema.sstable(1, 121), MockSchema.sstable(2, 9));
+ List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 17, cfs),
+ MockSchema.sstable(1, 121, cfs),
+ MockSchema.sstable(2, 9, cfs));
tracker.addInitialSSTables(copyOf(readers));
Assert.assertEquals(3, tracker.view.get().sstables.size());
@@ -163,7 +166,9 @@ public class TrackerTest
Tracker tracker = new Tracker(cfs, false);
MockListener listener = new MockListener(false);
tracker.subscribe(listener);
- List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 17), MockSchema.sstable(1, 121), MockSchema.sstable(2, 9));
+ List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 17, cfs),
+ MockSchema.sstable(1, 121, cfs),
+ MockSchema.sstable(2, 9, cfs));
tracker.addSSTables(copyOf(readers));
Assert.assertEquals(3, tracker.view.get().sstables.size());
@@ -193,7 +198,9 @@ public class TrackerTest
Tracker tracker = cfs.getTracker();
MockListener listener = new MockListener(false);
tracker.subscribe(listener);
- final List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 9, true), MockSchema.sstable(1, 15, true), MockSchema.sstable(2, 71, true));
+ final List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 9, true, cfs),
+ MockSchema.sstable(1, 15, true, cfs),
+ MockSchema.sstable(2, 71, true, cfs));
tracker.addInitialSSTables(copyOf(readers));
try
@@ -321,7 +328,8 @@ public class TrackerTest
@Test
public void testNotifications()
{
- SSTableReader r1 = MockSchema.sstable(0), r2 = MockSchema.sstable(1);
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ SSTableReader r1 = MockSchema.sstable(0, cfs), r2 = MockSchema.sstable(1, cfs);
Tracker tracker = new Tracker(null, false);
MockListener listener = new MockListener(false);
tracker.subscribe(listener);
@@ -338,7 +346,7 @@ public class TrackerTest
tracker.notifySSTableRepairedStatusChanged(singleton(r1));
Assert.assertEquals(singleton(r1), ((SSTableRepairStatusChanged) listener.received.get(0)).sstable);
listener.received.clear();
- Memtable memtable = MockSchema.memtable();
+ Memtable memtable = MockSchema.memtable(cfs);
tracker.notifyRenewed(memtable);
Assert.assertEquals(memtable, ((MemtableRenewedNotification) listener.received.get(0)).renewed);
listener.received.clear();
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99da2102/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java b/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
index 811e025..aa99fbd 100644
--- a/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
+++ b/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
@@ -30,6 +30,7 @@ import org.junit.Test;
import junit.framework.Assert;
import org.apache.cassandra.MockSchema;
+import org.apache.cassandra.db.ColumnFamilyStore;
import org.apache.cassandra.db.Memtable;
import org.apache.cassandra.db.RowPosition;
import org.apache.cassandra.dht.AbstractBounds;
@@ -46,7 +47,8 @@ public class ViewTest
@Test
public void testSSTablesInBounds()
{
- View initialView = fakeView(0, 5);
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ View initialView = fakeView(0, 5, cfs);
for (int i = 0 ; i < 5 ; i++)
{
for (int j = i ; j < 5 ; j++)
@@ -70,7 +72,8 @@ public class ViewTest
@Test
public void testCompaction()
{
- View initialView = fakeView(0, 5);
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ View initialView = fakeView(0, 5, cfs);
View cur = initialView;
List<SSTableReader> readers = ImmutableList.copyOf(initialView.sstables);
Assert.assertTrue(View.permitCompacting(readers).apply(cur));
@@ -96,7 +99,7 @@ public class ViewTest
testFailure(View.updateCompacting(copyOf(readers.subList(0, 1)), readers.subList(1, 2)), cur);
// make equivalents of readers.subList(0, 3) that are different instances
- SSTableReader r0 = MockSchema.sstable(0), r1 = MockSchema.sstable(1), r2 = MockSchema.sstable(2);
+ SSTableReader r0 = MockSchema.sstable(0, cfs), r1 = MockSchema.sstable(1, cfs), r2 = MockSchema.sstable(2, cfs);
// attempt to mark compacting a version not in the live set
testFailure(View.updateCompacting(emptySet(), of(r2)), cur);
// update one compacting, one non-compacting, of the liveset to another instance of the same readers;
@@ -138,17 +141,18 @@ public class ViewTest
@Test
public void testFlushing()
{
- View initialView = fakeView(1, 0);
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ View initialView = fakeView(1, 0, cfs);
View cur = initialView;
Memtable memtable1 = initialView.getCurrentMemtable();
- Memtable memtable2 = MockSchema.memtable();
+ Memtable memtable2 = MockSchema.memtable(cfs);
cur = View.switchMemtable(memtable2).apply(cur);
Assert.assertEquals(2, cur.liveMemtables.size());
Assert.assertEquals(memtable1, cur.liveMemtables.get(0));
Assert.assertEquals(memtable2, cur.getCurrentMemtable());
- Memtable memtable3 = MockSchema.memtable();
+ Memtable memtable3 = MockSchema.memtable(cfs);
cur = View.switchMemtable(memtable3).apply(cur);
Assert.assertEquals(3, cur.liveMemtables.size());
Assert.assertEquals(0, cur.flushingMemtables.size());
@@ -179,7 +183,7 @@ public class ViewTest
Assert.assertEquals(memtable1, cur.flushingMemtables.get(0));
Assert.assertEquals(memtable3, cur.getCurrentMemtable());
- SSTableReader sstable = MockSchema.sstable(1);
+ SSTableReader sstable = MockSchema.sstable(1, cfs);
cur = View.replaceFlushed(memtable1, sstable).apply(cur);
Assert.assertEquals(0, cur.flushingMemtables.size());
Assert.assertEquals(1, cur.liveMemtables.size());
@@ -188,14 +192,14 @@ public class ViewTest
Assert.assertEquals(sstable, cur.sstablesMap.get(sstable));
}
- static View fakeView(int memtableCount, int sstableCount)
+ static View fakeView(int memtableCount, int sstableCount, ColumnFamilyStore cfs)
{
List<Memtable> memtables = new ArrayList<>();
List<SSTableReader> sstables = new ArrayList<>();
for (int i = 0 ; i < memtableCount ; i++)
- memtables.add(MockSchema.memtable());
+ memtables.add(MockSchema.memtable(cfs));
for (int i = 0 ; i < sstableCount ; i++)
- sstables.add(MockSchema.sstable(i));
+ sstables.add(MockSchema.sstable(i, cfs));
return new View(ImmutableList.copyOf(memtables), Collections.<Memtable>emptyList(), Helpers.identityMap(sstables),
Collections.<SSTableReader>emptySet(), SSTableIntervalTree.build(sstables));
}
[3/9] cassandra git commit: Merge branch 'cassandra-2.1' into
cassandra-2.2
Posted by be...@apache.org.
Merge branch 'cassandra-2.1' into cassandra-2.2
Conflicts:
CHANGES.txt
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c1c78559
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c1c78559
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c1c78559
Branch: refs/heads/cassandra-2.2
Commit: c1c785593c72b6b853961f31dab9e2636d2876a2
Parents: 08a5dab 6250065
Author: Benedict Elliott Smith <be...@apache.org>
Authored: Wed Jun 3 13:03:59 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Wed Jun 3 13:03:59 2015 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../apache/cassandra/db/ColumnFamilyStore.java | 32 +++++++++++---------
2 files changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c1c78559/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 8124256,9ce5680..6f2c0ee
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,19 -1,5 +1,20 @@@
-2.1.6
+2.2
+ * Clean up gossiper logic for old versions (CASSANDRA-9370)
+ * Fix custom payload coding/decoding to match the spec (CASSANDRA-9515)
+ * ant test-all results incomplete when parsed (CASSANDRA-9463)
+ * Disallow frozen<> types in function arguments and return types for
+ clarity (CASSANDRA-9411)
+ * Static Analysis to warn on unsafe use of Autocloseable instances (CASSANDRA-9431)
+ * Update commitlog archiving examples now that commitlog segments are
+ not recycled (CASSANDRA-9350)
+ * Extend Transactional API to sstable lifecycle management (CASSANDRA-8568)
+ * (cqlsh) Add support for native protocol 4 (CASSANDRA-9399)
+ * Ensure that UDF and UDAs are keyspace-isolated (CASSANDRA-9409)
+ * Revert CASSANDRA-7807 (tracing completion client notifications) (CASSANDRA-9429)
+ * Add ability to stop compaction by ID (CASSANDRA-7207)
+ * Let CassandraVersion handle SNAPSHOT version (CASSANDRA-9438)
+Merged from 2.1:
+ * Ensure truncate without snapshot cannot produce corrupt responses (CASSANDRA-9388)
* Consistent error message when a table mixes counter and non-counter
columns (CASSANDRA-9492)
* Avoid getting unreadable keys during anticompaction (CASSANDRA-9508)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c1c78559/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
[5/9] cassandra git commit: Merge branch 'cassandra-2.2' into trunk
Posted by be...@apache.org.
Merge branch 'cassandra-2.2' into trunk
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b2215961
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b2215961
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b2215961
Branch: refs/heads/trunk
Commit: b221596106c8cb1e57a3f488ed3ce01f753726ac
Parents: e8fd1b1 c1c7855
Author: Benedict Elliott Smith <be...@apache.org>
Authored: Wed Jun 3 13:04:08 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Wed Jun 3 13:04:08 2015 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../apache/cassandra/db/ColumnFamilyStore.java | 32 +++++++++++---------
2 files changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/b2215961/CHANGES.txt
----------------------------------------------------------------------
[8/9] cassandra git commit: Merge branch 'cassandra-2.2' into trunk
Posted by be...@apache.org.
Merge branch 'cassandra-2.2' into trunk
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/6caade06
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/6caade06
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/6caade06
Branch: refs/heads/trunk
Commit: 6caade065c690d7f4cf0333a8c3efa8e09ef0ff0
Parents: b221596 99da210
Author: Benedict Elliott Smith <be...@apache.org>
Authored: Wed Jun 3 13:07:46 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Wed Jun 3 13:07:46 2015 +0100
----------------------------------------------------------------------
test/unit/org/apache/cassandra/MockSchema.java | 21 +++-----
.../cassandra/db/lifecycle/HelpersTest.java | 7 ++-
.../db/lifecycle/LifecycleTransactionTest.java | 52 ++++++++++++--------
.../cassandra/db/lifecycle/TrackerTest.java | 24 ++++++---
.../apache/cassandra/db/lifecycle/ViewTest.java | 24 +++++----
5 files changed, 74 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
[9/9] cassandra git commit: Switch SSTableDeletingTask.failingTasks
to a ConcurrentLinkedQueue
Posted by be...@apache.org.
Switch SSTableDeletingTask.failingTasks to a ConcurrentLinkedQueue
patch by benedict; reviewed by aleksey for CASSANDRA-9447
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/304eae3b
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/304eae3b
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/304eae3b
Branch: refs/heads/trunk
Commit: 304eae3b799759d334fcc50cbc3439608e1a2647
Parents: 6caade0
Author: Benedict Elliott Smith <be...@apache.org>
Authored: Wed Jun 3 13:08:28 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Wed Jun 3 13:08:28 2015 +0100
----------------------------------------------------------------------
.../apache/cassandra/io/sstable/SSTableDeletingTask.java | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/304eae3b/src/java/org/apache/cassandra/io/sstable/SSTableDeletingTask.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableDeletingTask.java b/src/java/org/apache/cassandra/io/sstable/SSTableDeletingTask.java
index cc837ba..13bfd6d 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableDeletingTask.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableDeletingTask.java
@@ -19,8 +19,9 @@ package org.apache.cassandra.io.sstable;
import java.io.File;
import java.util.Collections;
+import java.util.Queue;
import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.TimeUnit;
import com.google.common.annotations.VisibleForTesting;
@@ -42,7 +43,7 @@ public class SSTableDeletingTask implements Runnable
// and delete will fail (on Windows) until it is (we only force the unmapping on SUN VMs).
// Additionally, we need to make sure to delete the data file first, so on restart the others
// will be recognized as GCable.
- private static final Set<SSTableDeletingTask> failedTasks = new CopyOnWriteArraySet<>();
+ private static final Queue<SSTableDeletingTask> failedTasks = new ConcurrentLinkedQueue<>();
private static final Blocker blocker = new Blocker();
private final SSTableReader referent;
@@ -119,11 +120,9 @@ public class SSTableDeletingTask implements Runnable
*/
public static void rescheduleFailedTasks()
{
- for (SSTableDeletingTask task : failedTasks)
- {
- failedTasks.remove(task);
+ SSTableDeletingTask task;
+ while ( null != (task = failedTasks.poll()))
task.schedule();
- }
}
/** for tests */
[6/9] cassandra git commit: Do not reuse cfs in MockSchema
Posted by be...@apache.org.
Do not reuse cfs in MockSchema
patch by stefania; reviewed by benedict for CASSANDRA-9537
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/99da2102
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/99da2102
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/99da2102
Branch: refs/heads/trunk
Commit: 99da210229b9ddab8ce46d0664c46fe92282c6e3
Parents: c1c7855
Author: stefania <st...@datastax.com>
Authored: Wed Jun 3 13:07:21 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Wed Jun 3 13:07:21 2015 +0100
----------------------------------------------------------------------
test/unit/org/apache/cassandra/MockSchema.java | 21 +++-----
.../cassandra/db/lifecycle/HelpersTest.java | 7 ++-
.../db/lifecycle/LifecycleTransactionTest.java | 52 ++++++++++++--------
.../cassandra/db/lifecycle/TrackerTest.java | 24 ++++++---
.../apache/cassandra/db/lifecycle/ViewTest.java | 24 +++++----
5 files changed, 74 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99da2102/test/unit/org/apache/cassandra/MockSchema.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/MockSchema.java b/test/unit/org/apache/cassandra/MockSchema.java
index 86593c2..94313cd 100644
--- a/test/unit/org/apache/cassandra/MockSchema.java
+++ b/test/unit/org/apache/cassandra/MockSchema.java
@@ -62,38 +62,33 @@ public class MockSchema
}
private static final AtomicInteger id = new AtomicInteger();
public static final Keyspace ks = Keyspace.mockKS(new KSMetaData("mockks", SimpleStrategy.class, ImmutableMap.of("replication_factor", "1"), false));
- public static final ColumnFamilyStore cfs = newCFS();
private static final IndexSummary indexSummary;
private static final SegmentedFile segmentedFile = new BufferedSegmentedFile(new ChannelProxy(temp("mocksegmentedfile")), 0);
- public static Memtable memtable()
+ public static Memtable memtable(ColumnFamilyStore cfs)
{
return new Memtable(cfs.metadata);
}
- public static SSTableReader sstable(int generation)
+ public static SSTableReader sstable(int generation, ColumnFamilyStore cfs)
{
- return sstable(generation, false);
+ return sstable(generation, false, cfs);
}
- public static SSTableReader sstable(int generation, boolean keepRef)
+ public static SSTableReader sstable(int generation, boolean keepRef, ColumnFamilyStore cfs)
{
- return sstable(generation, 0, keepRef);
+ return sstable(generation, 0, keepRef, cfs);
}
- public static SSTableReader sstable(int generation, int size)
+ public static SSTableReader sstable(int generation, int size, ColumnFamilyStore cfs)
{
- return sstable(generation, size, false);
+ return sstable(generation, size, false, cfs);
}
- public static SSTableReader sstable(int generation, int size, boolean keepRef)
- {
- return sstable(generation, size, keepRef, cfs);
- }
public static SSTableReader sstable(int generation, int size, boolean keepRef, ColumnFamilyStore cfs)
{
- Descriptor descriptor = new Descriptor(temp("mockcfdir").getParentFile(), "mockks", "mockcf", generation, Descriptor.Type.FINAL);
+ Descriptor descriptor = new Descriptor(temp("mockcfdir").getParentFile(), ks.getName(), cfs.getColumnFamilyName(), generation, Descriptor.Type.FINAL);
Set<Component> components = ImmutableSet.of(Component.DATA, Component.PRIMARY_INDEX, Component.FILTER, Component.TOC);
for (Component component : components)
{
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99da2102/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java b/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
index d53a830..24d2bda 100644
--- a/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
+++ b/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
@@ -30,6 +30,7 @@ import org.junit.Test;
import junit.framework.Assert;
import org.apache.cassandra.MockSchema;
import org.apache.cassandra.Util;
+import org.apache.cassandra.db.ColumnFamilyStore;
import org.apache.cassandra.io.sstable.Descriptor;
import org.apache.cassandra.io.sstable.format.SSTableReader;
import org.apache.cassandra.io.sstable.format.big.BigTableReader;
@@ -135,7 +136,8 @@ public class HelpersTest
@Test
public void testSetupDeletionNotification()
{
- Iterable<SSTableReader> readers = Lists.newArrayList(MockSchema.sstable(1), MockSchema.sstable(2));
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ Iterable<SSTableReader> readers = Lists.newArrayList(MockSchema.sstable(1, cfs), MockSchema.sstable(2, cfs));
Throwable accumulate = Helpers.setReplaced(readers, null);
Assert.assertNull(accumulate);
for (SSTableReader reader : readers)
@@ -147,7 +149,8 @@ public class HelpersTest
@Test
public void testMarkObsolete()
{
- Iterable<SSTableReader> readers = Lists.newArrayList(MockSchema.sstable(1), MockSchema.sstable(2));
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ Iterable<SSTableReader> readers = Lists.newArrayList(MockSchema.sstable(1, cfs), MockSchema.sstable(2, cfs));
Throwable accumulate = Helpers.markObsolete(readers, null);
Assert.assertNull(accumulate);
for (SSTableReader reader : readers)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99da2102/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java b/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
index 3153ef1..2c6c830 100644
--- a/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
+++ b/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
@@ -28,11 +28,13 @@ import org.junit.Test;
import junit.framework.Assert;
import org.apache.cassandra.MockSchema;
import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.db.ColumnFamilyStore;
import org.apache.cassandra.db.compaction.OperationType;
import org.apache.cassandra.db.lifecycle.LifecycleTransaction.ReaderState;
import org.apache.cassandra.db.lifecycle.LifecycleTransaction.ReaderState.Action;
import org.apache.cassandra.io.sstable.SSTableDeletingTask;
import org.apache.cassandra.io.sstable.format.SSTableReader;
+import org.apache.cassandra.metrics.ColumnFamilyMetrics;
import org.apache.cassandra.utils.Pair;
import org.apache.cassandra.utils.concurrent.AbstractTransactionalTest;
import org.apache.cassandra.utils.concurrent.Transactional.AbstractTransactional.State;
@@ -66,10 +68,11 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
@Test
public void testUpdates() // (including obsoletion)
{
+ ColumnFamilyStore cfs = MockSchema.newCFS();
Tracker tracker = new Tracker(null, false);
- SSTableReader[] readers = readersArray(0, 3);
- SSTableReader[] readers2 = readersArray(0, 4);
- SSTableReader[] readers3 = readersArray(0, 4);
+ SSTableReader[] readers = readersArray(0, 3, cfs);
+ SSTableReader[] readers2 = readersArray(0, 4, cfs);
+ SSTableReader[] readers3 = readersArray(0, 4, cfs);
tracker.addInitialSSTables(copyOf(readers));
LifecycleTransaction txn = tracker.tryModify(copyOf(readers), OperationType.UNKNOWN);
@@ -129,15 +132,16 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
@Test
public void testCancellation()
{
+ ColumnFamilyStore cfs = MockSchema.newCFS();
Tracker tracker = new Tracker(null, false);
- List<SSTableReader> readers = readers(0, 3);
+ List<SSTableReader> readers = readers(0, 3, cfs);
tracker.addInitialSSTables(readers);
LifecycleTransaction txn = tracker.tryModify(readers, OperationType.UNKNOWN);
SSTableReader cancel = readers.get(0);
- SSTableReader update = readers(1, 2).get(0);
- SSTableReader fresh = readers(3, 4).get(0);
- SSTableReader notPresent = readers(4, 5).get(0);
+ SSTableReader update = readers(1, 2, cfs).get(0);
+ SSTableReader fresh = readers(3, 4,cfs).get(0);
+ SSTableReader notPresent = readers(4, 5, cfs).get(0);
txn.cancel(cancel);
txn.update(update, true);
@@ -172,8 +176,9 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
@Test
public void testSplit()
{
+ ColumnFamilyStore cfs = MockSchema.newCFS();
Tracker tracker = new Tracker(null, false);
- List<SSTableReader> readers = readers(0, 3);
+ List<SSTableReader> readers = readers(0, 3, cfs);
tracker.addInitialSSTables(readers);
LifecycleTransaction txn = tracker.tryModify(readers, OperationType.UNKNOWN);
LifecycleTransaction txn2 = txn.split(readers.subList(0, 1));
@@ -181,7 +186,7 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
Assert.assertTrue(all(readers.subList(1, 3), in(txn.originals())));
Assert.assertEquals(1, txn2.originals().size());
Assert.assertTrue(all(readers.subList(0, 1), in(txn2.originals())));
- txn.update(readers(1, 2).get(0), true);
+ txn.update(readers(1, 2, cfs).get(0), true);
boolean failed = false;
try
{
@@ -255,21 +260,26 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
final Tracker tracker;
final LifecycleTransaction txn;
- private static Tracker tracker(List<SSTableReader> readers)
+ private static Tracker tracker(ColumnFamilyStore cfs, List<SSTableReader> readers)
{
- Tracker tracker = new Tracker(MockSchema.cfs, false);
+ Tracker tracker = new Tracker(cfs, false);
tracker.addInitialSSTables(readers);
return tracker;
}
private TxnTest()
{
- this(readers(0, 8));
+ this(MockSchema.newCFS());
}
- private TxnTest(List<SSTableReader> readers)
+ private TxnTest(ColumnFamilyStore cfs)
{
- this(tracker(readers), readers);
+ this(cfs, readers(0, 8, cfs));
+ }
+
+ private TxnTest(ColumnFamilyStore cfs, List<SSTableReader> readers)
+ {
+ this(tracker(cfs, readers), readers);
}
private TxnTest(Tracker tracker, List<SSTableReader> readers)
@@ -283,11 +293,11 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
this.tracker = tracker;
this.originals = readers;
this.txn = txn;
- update(txn, loggedUpdate = readers(0, 2), true);
+ update(txn, loggedUpdate = readers(0, 2, tracker.cfstore), true);
obsolete(txn, loggedObsolete = readers.subList(2, 4));
- update(txn, loggedNew = readers(8, 10), false);
+ update(txn, loggedNew = readers(8, 10, tracker.cfstore), false);
txn.checkpoint();
- update(txn, stagedNew = readers(10, 12), false);
+ update(txn, stagedNew = readers(10, 12, tracker.cfstore), false);
obsolete(txn, stagedObsolete = copyOf(concat(loggedUpdate, originals.subList(4, 6))));
untouchedOriginals = originals.subList(6, 8);
}
@@ -385,16 +395,16 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
}
}
- private static SSTableReader[] readersArray(int lb, int ub)
+ private static SSTableReader[] readersArray(int lb, int ub, ColumnFamilyStore cfs)
{
- return readers(lb, ub).toArray(new SSTableReader[0]);
+ return readers(lb, ub, cfs).toArray(new SSTableReader[0]);
}
- private static List<SSTableReader> readers(int lb, int ub)
+ private static List<SSTableReader> readers(int lb, int ub, ColumnFamilyStore cfs)
{
List<SSTableReader> readers = new ArrayList<>();
for (int i = lb ; i < ub ; i++)
- readers.add(MockSchema.sstable(i, i, true));
+ readers.add(MockSchema.sstable(i, i, true, cfs));
return copyOf(readers);
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99da2102/test/unit/org/apache/cassandra/db/lifecycle/TrackerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/lifecycle/TrackerTest.java b/test/unit/org/apache/cassandra/db/lifecycle/TrackerTest.java
index 1859e70..0d46153 100644
--- a/test/unit/org/apache/cassandra/db/lifecycle/TrackerTest.java
+++ b/test/unit/org/apache/cassandra/db/lifecycle/TrackerTest.java
@@ -82,7 +82,7 @@ public class TrackerTest
{
ColumnFamilyStore cfs = MockSchema.newCFS();
Tracker tracker = new Tracker(cfs, false);
- List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0), MockSchema.sstable(1), MockSchema.sstable(2));
+ List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, cfs), MockSchema.sstable(1, cfs), MockSchema.sstable(2, cfs));
tracker.addInitialSSTables(copyOf(readers));
try (LifecycleTransaction txn = tracker.tryModify(readers.get(0), OperationType.COMPACTION);)
{
@@ -101,8 +101,9 @@ public class TrackerTest
@Test
public void testApply()
{
+ final ColumnFamilyStore cfs = MockSchema.newCFS();
final Tracker tracker = new Tracker(null, false);
- final View resultView = ViewTest.fakeView(0, 0);
+ final View resultView = ViewTest.fakeView(0, 0, cfs);
final AtomicInteger count = new AtomicInteger();
tracker.apply(new Predicate<View>()
{
@@ -110,7 +111,7 @@ public class TrackerTest
{
// confound the CAS by swapping the view, and check we retry
if (count.incrementAndGet() < 3)
- tracker.view.set(ViewTest.fakeView(0, 0));
+ tracker.view.set(ViewTest.fakeView(0, 0, cfs));
return true;
}
}, new Function<View, View>()
@@ -143,7 +144,9 @@ public class TrackerTest
{
ColumnFamilyStore cfs = MockSchema.newCFS();
Tracker tracker = new Tracker(cfs, false);
- List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 17), MockSchema.sstable(1, 121), MockSchema.sstable(2, 9));
+ List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 17, cfs),
+ MockSchema.sstable(1, 121, cfs),
+ MockSchema.sstable(2, 9, cfs));
tracker.addInitialSSTables(copyOf(readers));
Assert.assertEquals(3, tracker.view.get().sstables.size());
@@ -163,7 +166,9 @@ public class TrackerTest
Tracker tracker = new Tracker(cfs, false);
MockListener listener = new MockListener(false);
tracker.subscribe(listener);
- List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 17), MockSchema.sstable(1, 121), MockSchema.sstable(2, 9));
+ List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 17, cfs),
+ MockSchema.sstable(1, 121, cfs),
+ MockSchema.sstable(2, 9, cfs));
tracker.addSSTables(copyOf(readers));
Assert.assertEquals(3, tracker.view.get().sstables.size());
@@ -193,7 +198,9 @@ public class TrackerTest
Tracker tracker = cfs.getTracker();
MockListener listener = new MockListener(false);
tracker.subscribe(listener);
- final List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 9, true), MockSchema.sstable(1, 15, true), MockSchema.sstable(2, 71, true));
+ final List<SSTableReader> readers = ImmutableList.of(MockSchema.sstable(0, 9, true, cfs),
+ MockSchema.sstable(1, 15, true, cfs),
+ MockSchema.sstable(2, 71, true, cfs));
tracker.addInitialSSTables(copyOf(readers));
try
@@ -321,7 +328,8 @@ public class TrackerTest
@Test
public void testNotifications()
{
- SSTableReader r1 = MockSchema.sstable(0), r2 = MockSchema.sstable(1);
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ SSTableReader r1 = MockSchema.sstable(0, cfs), r2 = MockSchema.sstable(1, cfs);
Tracker tracker = new Tracker(null, false);
MockListener listener = new MockListener(false);
tracker.subscribe(listener);
@@ -338,7 +346,7 @@ public class TrackerTest
tracker.notifySSTableRepairedStatusChanged(singleton(r1));
Assert.assertEquals(singleton(r1), ((SSTableRepairStatusChanged) listener.received.get(0)).sstable);
listener.received.clear();
- Memtable memtable = MockSchema.memtable();
+ Memtable memtable = MockSchema.memtable(cfs);
tracker.notifyRenewed(memtable);
Assert.assertEquals(memtable, ((MemtableRenewedNotification) listener.received.get(0)).renewed);
listener.received.clear();
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99da2102/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java b/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
index 811e025..aa99fbd 100644
--- a/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
+++ b/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
@@ -30,6 +30,7 @@ import org.junit.Test;
import junit.framework.Assert;
import org.apache.cassandra.MockSchema;
+import org.apache.cassandra.db.ColumnFamilyStore;
import org.apache.cassandra.db.Memtable;
import org.apache.cassandra.db.RowPosition;
import org.apache.cassandra.dht.AbstractBounds;
@@ -46,7 +47,8 @@ public class ViewTest
@Test
public void testSSTablesInBounds()
{
- View initialView = fakeView(0, 5);
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ View initialView = fakeView(0, 5, cfs);
for (int i = 0 ; i < 5 ; i++)
{
for (int j = i ; j < 5 ; j++)
@@ -70,7 +72,8 @@ public class ViewTest
@Test
public void testCompaction()
{
- View initialView = fakeView(0, 5);
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ View initialView = fakeView(0, 5, cfs);
View cur = initialView;
List<SSTableReader> readers = ImmutableList.copyOf(initialView.sstables);
Assert.assertTrue(View.permitCompacting(readers).apply(cur));
@@ -96,7 +99,7 @@ public class ViewTest
testFailure(View.updateCompacting(copyOf(readers.subList(0, 1)), readers.subList(1, 2)), cur);
// make equivalents of readers.subList(0, 3) that are different instances
- SSTableReader r0 = MockSchema.sstable(0), r1 = MockSchema.sstable(1), r2 = MockSchema.sstable(2);
+ SSTableReader r0 = MockSchema.sstable(0, cfs), r1 = MockSchema.sstable(1, cfs), r2 = MockSchema.sstable(2, cfs);
// attempt to mark compacting a version not in the live set
testFailure(View.updateCompacting(emptySet(), of(r2)), cur);
// update one compacting, one non-compacting, of the liveset to another instance of the same readers;
@@ -138,17 +141,18 @@ public class ViewTest
@Test
public void testFlushing()
{
- View initialView = fakeView(1, 0);
+ ColumnFamilyStore cfs = MockSchema.newCFS();
+ View initialView = fakeView(1, 0, cfs);
View cur = initialView;
Memtable memtable1 = initialView.getCurrentMemtable();
- Memtable memtable2 = MockSchema.memtable();
+ Memtable memtable2 = MockSchema.memtable(cfs);
cur = View.switchMemtable(memtable2).apply(cur);
Assert.assertEquals(2, cur.liveMemtables.size());
Assert.assertEquals(memtable1, cur.liveMemtables.get(0));
Assert.assertEquals(memtable2, cur.getCurrentMemtable());
- Memtable memtable3 = MockSchema.memtable();
+ Memtable memtable3 = MockSchema.memtable(cfs);
cur = View.switchMemtable(memtable3).apply(cur);
Assert.assertEquals(3, cur.liveMemtables.size());
Assert.assertEquals(0, cur.flushingMemtables.size());
@@ -179,7 +183,7 @@ public class ViewTest
Assert.assertEquals(memtable1, cur.flushingMemtables.get(0));
Assert.assertEquals(memtable3, cur.getCurrentMemtable());
- SSTableReader sstable = MockSchema.sstable(1);
+ SSTableReader sstable = MockSchema.sstable(1, cfs);
cur = View.replaceFlushed(memtable1, sstable).apply(cur);
Assert.assertEquals(0, cur.flushingMemtables.size());
Assert.assertEquals(1, cur.liveMemtables.size());
@@ -188,14 +192,14 @@ public class ViewTest
Assert.assertEquals(sstable, cur.sstablesMap.get(sstable));
}
- static View fakeView(int memtableCount, int sstableCount)
+ static View fakeView(int memtableCount, int sstableCount, ColumnFamilyStore cfs)
{
List<Memtable> memtables = new ArrayList<>();
List<SSTableReader> sstables = new ArrayList<>();
for (int i = 0 ; i < memtableCount ; i++)
- memtables.add(MockSchema.memtable());
+ memtables.add(MockSchema.memtable(cfs));
for (int i = 0 ; i < sstableCount ; i++)
- sstables.add(MockSchema.sstable(i));
+ sstables.add(MockSchema.sstable(i, cfs));
return new View(ImmutableList.copyOf(memtables), Collections.<Memtable>emptyList(), Helpers.identityMap(sstables),
Collections.<SSTableReader>emptySet(), SSTableIntervalTree.build(sstables));
}
[4/9] cassandra git commit: Merge branch 'cassandra-2.1' into
cassandra-2.2
Posted by be...@apache.org.
Merge branch 'cassandra-2.1' into cassandra-2.2
Conflicts:
CHANGES.txt
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c1c78559
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c1c78559
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c1c78559
Branch: refs/heads/trunk
Commit: c1c785593c72b6b853961f31dab9e2636d2876a2
Parents: 08a5dab 6250065
Author: Benedict Elliott Smith <be...@apache.org>
Authored: Wed Jun 3 13:03:59 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Wed Jun 3 13:03:59 2015 +0100
----------------------------------------------------------------------
CHANGES.txt | 1 +
.../apache/cassandra/db/ColumnFamilyStore.java | 32 +++++++++++---------
2 files changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c1c78559/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 8124256,9ce5680..6f2c0ee
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,19 -1,5 +1,20 @@@
-2.1.6
+2.2
+ * Clean up gossiper logic for old versions (CASSANDRA-9370)
+ * Fix custom payload coding/decoding to match the spec (CASSANDRA-9515)
+ * ant test-all results incomplete when parsed (CASSANDRA-9463)
+ * Disallow frozen<> types in function arguments and return types for
+ clarity (CASSANDRA-9411)
+ * Static Analysis to warn on unsafe use of Autocloseable instances (CASSANDRA-9431)
+ * Update commitlog archiving examples now that commitlog segments are
+ not recycled (CASSANDRA-9350)
+ * Extend Transactional API to sstable lifecycle management (CASSANDRA-8568)
+ * (cqlsh) Add support for native protocol 4 (CASSANDRA-9399)
+ * Ensure that UDF and UDAs are keyspace-isolated (CASSANDRA-9409)
+ * Revert CASSANDRA-7807 (tracing completion client notifications) (CASSANDRA-9429)
+ * Add ability to stop compaction by ID (CASSANDRA-7207)
+ * Let CassandraVersion handle SNAPSHOT version (CASSANDRA-9438)
+Merged from 2.1:
+ * Ensure truncate without snapshot cannot produce corrupt responses (CASSANDRA-9388)
* Consistent error message when a table mixes counter and non-counter
columns (CASSANDRA-9492)
* Avoid getting unreadable keys during anticompaction (CASSANDRA-9508)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/c1c78559/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------