Search in sources :

Example 21 with EndpointsForToken

use of org.apache.cassandra.locator.EndpointsForToken in project cassandra by apache.

the class DigestResolverTest method agreeingTransient.

/**
 * A full response and a transient response, with the transient response being a subset of the full one
 */
@Test
public void agreeingTransient() {
    SinglePartitionReadCommand command = SinglePartitionReadCommand.fullPartitionRead(cfm, nowInSec, dk);
    EndpointsForToken targetReplicas = EndpointsForToken.of(dk.getToken(), full(EP1), trans(EP2));
    DigestResolver<?, ?> resolver = new DigestResolver<>(command, plan(ConsistencyLevel.QUORUM, targetReplicas), 0);
    PartitionUpdate response1 = update(row(1000, 4, 4), row(1000, 5, 5)).build();
    PartitionUpdate response2 = update(row(1000, 5, 5)).build();
    Assert.assertFalse(resolver.isDataPresent());
    resolver.preprocess(response(command, EP1, iter(response1), false));
    resolver.preprocess(response(command, EP2, iter(response2), false));
    Assert.assertTrue(resolver.isDataPresent());
    Assert.assertTrue(resolver.responsesMatch());
    Assert.assertTrue(resolver.hasTransientResponse());
}
Also used : EndpointsForToken(org.apache.cassandra.locator.EndpointsForToken) SinglePartitionReadCommand(org.apache.cassandra.db.SinglePartitionReadCommand) PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate) Test(org.junit.Test)

Aggregations

EndpointsForToken (org.apache.cassandra.locator.EndpointsForToken)21 Test (org.junit.Test)9 SinglePartitionReadCommand (org.apache.cassandra.db.SinglePartitionReadCommand)8 PartitionUpdate (org.apache.cassandra.db.partitions.PartitionUpdate)8 Token (org.apache.cassandra.dht.Token)8 Replica (org.apache.cassandra.locator.Replica)6 ReplicaPlan (org.apache.cassandra.locator.ReplicaPlan)5 Keyspace (org.apache.cassandra.db.Keyspace)4 InetAddressAndPort (org.apache.cassandra.locator.InetAddressAndPort)4 ReplicaLayout (org.apache.cassandra.locator.ReplicaLayout)4 UncheckedInterruptedException (org.apache.cassandra.utils.concurrent.UncheckedInterruptedException)4 List (java.util.List)3 UUID (java.util.UUID)3 Collectors (java.util.stream.Collectors)3 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)3 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)3 ConsistencyLevel (org.apache.cassandra.db.ConsistencyLevel)3 IMutation (org.apache.cassandra.db.IMutation)3 Mutation (org.apache.cassandra.db.Mutation)3 ReadFailureException (org.apache.cassandra.exceptions.ReadFailureException)3