use of org.apache.cassandra.locator.Replica 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.Replica in project cassandra by apache.
the class ReadRepairTest method mutationsArentSentToInSyncNodes.
/**
* If we didn't send a repair to a replica because there wasn't a diff with the
* resolved column family, we shouldn't send it a speculative mutation
*/
@Test
public void mutationsArentSentToInSyncNodes() throws Exception {
Mutation repair1 = mutation(cell2);
Map<Replica, Mutation> repairs = new HashMap<>();
repairs.put(target1, repair1);
// check that the correct initial mutations are sent out
InstrumentedReadRepairHandler handler = createRepairHandler(repairs, targets, EndpointsForRange.of(target1, target2));
handler.sendInitialRepairs();
Assert.assertEquals(1, handler.mutationsSent.size());
Assert.assertTrue(handler.mutationsSent.containsKey(target1.endpoint()));
// check that speculative mutations aren't sent to target2
handler.mutationsSent.clear();
handler.maybeSendAdditionalWrites(0, TimeUnit.NANOSECONDS);
Assert.assertEquals(1, handler.mutationsSent.size());
Assert.assertTrue(handler.mutationsSent.containsKey(target3.endpoint()));
}
use of org.apache.cassandra.locator.Replica 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));
}
use of org.apache.cassandra.locator.Replica in project cassandra by apache.
the class ReadRepairTest method additionalMutationRequired.
@Test
public void additionalMutationRequired() throws Exception {
Mutation repair1 = mutation(cell2);
Mutation repair2 = mutation(cell1);
// check that the correct repairs are calculated
Map<Replica, Mutation> repairs = new HashMap<>();
repairs.put(target1, repair1);
repairs.put(target2, repair2);
InstrumentedReadRepairHandler<?, ?> handler = createRepairHandler(repairs, targets, EndpointsForRange.of(target1, target2));
Assert.assertTrue(handler.mutationsSent.isEmpty());
// check that the correct mutations are sent
handler.sendInitialRepairs();
Assert.assertEquals(2, handler.mutationsSent.size());
assertMutationEqual(repair1, handler.mutationsSent.get(target1.endpoint()));
assertMutationEqual(repair2, handler.mutationsSent.get(target2.endpoint()));
// check that a combined mutation is speculatively sent to the 3rd target
handler.mutationsSent.clear();
handler.maybeSendAdditionalWrites(0, TimeUnit.NANOSECONDS);
Assert.assertEquals(1, handler.mutationsSent.size());
assertMutationEqual(resolved, handler.mutationsSent.get(target3.endpoint()));
// check repairs stop blocking after receiving 2 acks
Assert.assertFalse(getCurrentRepairStatus(handler));
handler.ack(target1.endpoint());
Assert.assertFalse(getCurrentRepairStatus(handler));
handler.ack(target3.endpoint());
Assert.assertTrue(getCurrentRepairStatus(handler));
}
Aggregations