Search in sources :

Example 41 with EndpointsForRange

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);
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) EndpointsForRange(org.apache.cassandra.locator.EndpointsForRange) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 42 with EndpointsForRange

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());
}
Also used : HashMap(java.util.HashMap) EndpointsForRange(org.apache.cassandra.locator.EndpointsForRange) Mutation(org.apache.cassandra.db.Mutation) Replica(org.apache.cassandra.locator.Replica) Test(org.junit.Test)

Example 43 with EndpointsForRange

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));
}
Also used : HashMap(java.util.HashMap) EndpointsForRange(org.apache.cassandra.locator.EndpointsForRange) Mutation(org.apache.cassandra.db.Mutation) Replica(org.apache.cassandra.locator.Replica) Test(org.junit.Test)

Example 44 with EndpointsForRange

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));
}
Also used : HashMap(java.util.HashMap) EndpointsForRange(org.apache.cassandra.locator.EndpointsForRange) Mutation(org.apache.cassandra.db.Mutation) Replica(org.apache.cassandra.locator.Replica) Test(org.junit.Test)

Aggregations

EndpointsForRange (org.apache.cassandra.locator.EndpointsForRange)44 InetAddressAndPort (org.apache.cassandra.locator.InetAddressAndPort)36 Test (org.junit.Test)32 Mutation (org.apache.cassandra.db.Mutation)18 PartitionIterator (org.apache.cassandra.db.partitions.PartitionIterator)16 UnfilteredPartitionIterator (org.apache.cassandra.db.partitions.UnfilteredPartitionIterator)16 ByteBuffer (java.nio.ByteBuffer)14 RowUpdateBuilder (org.apache.cassandra.db.RowUpdateBuilder)13 BTreeRow (org.apache.cassandra.db.rows.BTreeRow)10 Row (org.apache.cassandra.db.rows.Row)10 Replica (org.apache.cassandra.locator.Replica)10 RowIterator (org.apache.cassandra.db.rows.RowIterator)9 DeletionTime (org.apache.cassandra.db.DeletionTime)8 HashMap (java.util.HashMap)6 Token (org.apache.cassandra.dht.Token)6 TestableReadRepair (org.apache.cassandra.service.reads.repair.TestableReadRepair)6 RangeTombstone (org.apache.cassandra.db.RangeTombstone)5 ReadCommand (org.apache.cassandra.db.ReadCommand)4 EndpointsByReplica (org.apache.cassandra.locator.EndpointsByReplica)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3