use of org.apache.cassandra.locator.EndpointsForRange in project cassandra by apache.
the class DataResolverTest method trackMatchingDigestsWithNoneConclusive.
@Test
public void trackMatchingDigestsWithNoneConclusive() {
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, false);
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, false, 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 ReadRepairTest method noAdditionalMutationRequired.
/**
* If we've received enough acks, we shouldn't send any additional mutations
*/
@Test
public void noAdditionalMutationRequired() throws Exception {
Map<Replica, Mutation> repairs = new HashMap<>();
repairs.put(target1, mutation(cell2));
repairs.put(target2, mutation(cell1));
EndpointsForRange replicas = EndpointsForRange.of(target1, target2);
InstrumentedReadRepairHandler handler = createRepairHandler(repairs, replicas, targets);
handler.sendInitialRepairs();
handler.ack(target1.endpoint());
handler.ack(target2.endpoint());
// both replicas have acked, we shouldn't send anything else out
handler.mutationsSent.clear();
handler.maybeSendAdditionalWrites(0, TimeUnit.NANOSECONDS);
Assert.assertTrue(handler.mutationsSent.isEmpty());
}
use of org.apache.cassandra.locator.EndpointsForRange in project cassandra by apache.
the class ReadRepairTest method remoteDCTest.
/**
* For dc local consistency levels, noop mutations and responses from remote dcs should not affect effective blockFor
*/
@Test
public void remoteDCTest() throws Exception {
Map<Replica, Mutation> repairs = new HashMap<>();
repairs.put(target1, mutation(cell1));
Replica remote1 = full(InetAddressAndPort.getByName("10.0.0.1"));
Replica remote2 = full(InetAddressAndPort.getByName("10.0.0.2"));
repairs.put(remote1, mutation(cell1));
EndpointsForRange participants = EndpointsForRange.of(target1, target2, remote1, remote2);
EndpointsForRange targets = EndpointsForRange.of(target1, target2);
InstrumentedReadRepairHandler handler = createRepairHandler(repairs, participants, targets);
handler.sendInitialRepairs();
Assert.assertEquals(2, handler.mutationsSent.size());
Assert.assertTrue(handler.mutationsSent.containsKey(target1.endpoint()));
Assert.assertTrue(handler.mutationsSent.containsKey(remote1.endpoint()));
Assert.assertEquals(1, handler.waitingOn());
Assert.assertFalse(getCurrentRepairStatus(handler));
handler.ack(remote1.endpoint());
Assert.assertEquals(1, handler.waitingOn());
Assert.assertFalse(getCurrentRepairStatus(handler));
handler.ack(target1.endpoint());
Assert.assertEquals(0, handler.waitingOn());
Assert.assertTrue(getCurrentRepairStatus(handler));
}
use of org.apache.cassandra.locator.EndpointsForRange in project cassandra by apache.
the class ReadRepairTest method onlyBlockOnQuorum.
@Test
public void onlyBlockOnQuorum() {
Map<Replica, Mutation> repairs = new HashMap<>();
repairs.put(target1, mutation(cell1));
repairs.put(target2, mutation(cell2));
repairs.put(target3, mutation(cell3));
Assert.assertEquals(3, repairs.size());
EndpointsForRange replicas = EndpointsForRange.of(target1, target2, target3);
InstrumentedReadRepairHandler handler = createRepairHandler(repairs, replicas, replicas);
handler.sendInitialRepairs();
Assert.assertFalse(getCurrentRepairStatus(handler));
handler.ack(target1.endpoint());
Assert.assertFalse(getCurrentRepairStatus(handler));
// here we should stop blocking, even though we've sent 3 repairs
handler.ack(target2.endpoint());
Assert.assertTrue(getCurrentRepairStatus(handler));
}
Aggregations