use of org.apache.cassandra.locator.EndpointsForRange in project cassandra by apache.
the class DataResolverTest method testResolveNewCollectionOverwritingDeleted.
@Test
public void testResolveNewCollectionOverwritingDeleted() {
EndpointsForRange replicas = makeReplicas(2);
ReadCommand cmd = Util.cmd(cfs2, dk).withNowInSeconds(nowInSec).build();
TestableReadRepair readRepair = new TestableReadRepair(cmd);
DataResolver resolver = new DataResolver(cmd, plan(replicas, ALL), readRepair, nanoTime());
long[] ts = { 100, 200 };
// cleared map column
Row.Builder builder = BTreeRow.unsortedBuilder();
builder.newRow(Clustering.EMPTY);
builder.addComplexDeletion(m, new DeletionTime(ts[0] - 1, nowInSec));
InetAddressAndPort peer1 = replicas.get(0).endpoint();
resolver.preprocess(response(cmd, peer1, iter(PartitionUpdate.singleRowUpdate(cfm2, dk, builder.build()))));
// newer, overwritten map column
builder.newRow(Clustering.EMPTY);
DeletionTime expectedCmplxDelete = new DeletionTime(ts[1] - 1, nowInSec);
builder.addComplexDeletion(m, expectedCmplxDelete);
Cell<?> expectedCell = mapCell(1, 1, ts[1]);
builder.addCell(expectedCell);
InetAddressAndPort peer2 = replicas.get(1).endpoint();
resolver.preprocess(response(cmd, peer2, iter(PartitionUpdate.singleRowUpdate(cfm2, dk, builder.build()))));
try (PartitionIterator data = resolver.resolve()) {
try (RowIterator rows = Iterators.getOnlyElement(data)) {
Row row = Iterators.getOnlyElement(rows);
assertColumns(row, "m");
ComplexColumnData cd = row.getComplexColumnData(m);
assertEquals(Collections.singleton(expectedCell), Sets.newHashSet(cd));
}
}
Row row = Iterators.getOnlyElement(readRepair.getForEndpoint(peer1).getPartitionUpdate(cfm2).iterator());
ComplexColumnData cd = row.getComplexColumnData(m);
assertEquals(Collections.singleton(expectedCell), Sets.newHashSet(cd));
assertEquals(expectedCmplxDelete, cd.complexDeletion());
Assert.assertNull(readRepair.sent.get(peer2));
}
use of org.apache.cassandra.locator.EndpointsForRange in project cassandra by apache.
the class DataResolverTest method trackMismatchingRepairedDigestsWithSomeConclusive.
@Test
public void trackMismatchingRepairedDigestsWithSomeConclusive() {
ByteBuffer digest1 = ByteBufferUtil.bytes("digest1");
ByteBuffer digest2 = ByteBufferUtil.bytes("digest2");
EndpointsForRange replicas = makeReplicas(2);
InetAddressAndPort peer1 = replicas.get(0).endpoint();
InetAddressAndPort peer2 = replicas.get(1).endpoint();
TestRepairedDataVerifier verifier = new TestRepairedDataVerifier();
verifier.expectDigest(peer1, digest1, false);
verifier.expectDigest(peer2, digest2, true);
DataResolver resolver = resolverWithVerifier(command, plan(replicas, ALL), readRepair, nanoTime(), verifier);
resolver.preprocess(response(peer1, iter(PartitionUpdate.emptyUpdate(cfm, dk)), digest1, false, command));
resolver.preprocess(response(peer2, iter(PartitionUpdate.emptyUpdate(cfm, dk)), digest2, true, command));
resolveAndConsume(resolver);
assertTrue(verifier.verified);
}
use of org.apache.cassandra.locator.EndpointsForRange in project cassandra by apache.
the class DataResolverTest method trackMatchingDigestsWithSomeConclusive.
@Test
public void trackMatchingDigestsWithSomeConclusive() {
ByteBuffer digest1 = ByteBufferUtil.bytes("digest1");
EndpointsForRange replicas = makeReplicas(2);
InetAddressAndPort peer1 = replicas.get(0).endpoint();
InetAddressAndPort peer2 = replicas.get(1).endpoint();
TestRepairedDataVerifier verifier = new TestRepairedDataVerifier();
verifier.expectDigest(peer1, digest1, true);
verifier.expectDigest(peer2, digest1, false);
DataResolver resolver = resolverWithVerifier(command, plan(replicas, ALL), readRepair, nanoTime(), verifier);
resolver.preprocess(response(peer1, iter(PartitionUpdate.emptyUpdate(cfm, dk)), digest1, true, command));
resolver.preprocess(response(peer2, iter(PartitionUpdate.emptyUpdate(cfm, dk)), digest1, false, command));
resolveAndConsume(resolver);
assertTrue(verifier.verified);
}
use of org.apache.cassandra.locator.EndpointsForRange in project cassandra by apache.
the class DataResolverTest method trackMatchingRepairedDigestsWithDifferentData.
@Test
public void trackMatchingRepairedDigestsWithDifferentData() {
// As far as repaired data tracking is concerned, the actual data in the response is not relevant
EndpointsForRange replicas = makeReplicas(2);
ByteBuffer digest1 = ByteBufferUtil.bytes("digest1");
InetAddressAndPort peer1 = replicas.get(0).endpoint();
InetAddressAndPort peer2 = replicas.get(1).endpoint();
TestRepairedDataVerifier verifier = new TestRepairedDataVerifier();
verifier.expectDigest(peer1, digest1, true);
verifier.expectDigest(peer2, digest1, true);
DataResolver resolver = resolverWithVerifier(command, plan(replicas, ALL), readRepair, nanoTime(), verifier);
resolver.preprocess(response(peer1, iter(new RowUpdateBuilder(cfm, nowInSec, 1L, dk).clustering("1").buildUpdate()), digest1, true, command));
resolver.preprocess(response(peer2, iter(PartitionUpdate.emptyUpdate(cfm, dk)), digest1, true, command));
resolveAndConsume(resolver);
assertTrue(verifier.verified);
}
use of org.apache.cassandra.locator.EndpointsForRange in project cassandra by apache.
the class DataResolverTest method responsesFromOlderVersionsAreNotTracked.
@Test
public void responsesFromOlderVersionsAreNotTracked() {
// In a mixed version cluster, responses from a replicas running older versions won't include
// tracking info, so the digest and pending session status are defaulted. To make sure these
// default values don't result in false positives we make sure not to consider them when
// processing in DataResolver
EndpointsForRange replicas = makeReplicas(2);
TestRepairedDataVerifier verifier = new TestRepairedDataVerifier();
ByteBuffer digest1 = ByteBufferUtil.bytes("digest1");
InetAddressAndPort peer1 = replicas.get(0).endpoint();
InetAddressAndPort peer2 = replicas.get(1).endpoint();
verifier.expectDigest(peer1, digest1, true);
DataResolver resolver = resolverWithVerifier(command, plan(replicas, ALL), readRepair, nanoTime(), verifier);
resolver.preprocess(response(peer1, iter(PartitionUpdate.emptyUpdate(cfm, dk)), digest1, true, command));
// peer2 is advertising an older version, so when we deserialize its response there are two things to note:
// i) the actual serialized response cannot contain any tracking info so deserialization will use defaults of
// an empty digest and pending sessions = false
// ii) under normal circumstances, this would cause a mismatch with peer1, but because of the older version,
// here it will not
resolver.preprocess(response(command, peer2, iter(PartitionUpdate.emptyUpdate(cfm, dk)), false, MessagingService.VERSION_30, ByteBufferUtil.EMPTY_BYTE_BUFFER, false));
resolveAndConsume(resolver);
assertTrue(verifier.verified);
}
Aggregations