use of org.apache.cassandra.db.SinglePartitionReadCommand in project cassandra by apache.
the class Ballots method latestBallotFromBaseTable.
public static long latestBallotFromBaseTable(DecoratedKey key, TableMetadata metadata) {
SinglePartitionReadCommand cmd = SinglePartitionReadCommand.create(metadata, 0, key, Slice.ALL);
ImmutableBTreePartition partition;
try (ReadExecutionController controller = cmd.executionController();
UnfilteredPartitionIterator partitions = cmd.executeLocally(controller)) {
if (!partitions.hasNext())
return 0L;
try (UnfilteredRowIterator rows = partitions.next()) {
partition = ImmutableBTreePartition.create(rows);
}
}
return latestBallot(partition);
}
use of org.apache.cassandra.db.SinglePartitionReadCommand in project cassandra by apache.
the class DigestResolverTest method digestMismatch.
@Test
public void digestMismatch() {
SinglePartitionReadCommand command = SinglePartitionReadCommand.fullPartitionRead(cfm, nowInSec, dk);
EndpointsForToken targetReplicas = EndpointsForToken.of(dk.getToken(), full(EP1), full(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(2000, 4, 5)).build();
Assert.assertFalse(resolver.isDataPresent());
resolver.preprocess(response(command, EP2, iter(response1), true));
resolver.preprocess(response(command, EP1, iter(response2), false));
Assert.assertTrue(resolver.isDataPresent());
Assert.assertFalse(resolver.responsesMatch());
Assert.assertFalse(resolver.hasTransientResponse());
}
use of org.apache.cassandra.db.SinglePartitionReadCommand in project cassandra by apache.
the class DigestResolverTest method noRepairNeeded.
@Test
public void noRepairNeeded() {
SinglePartitionReadCommand command = SinglePartitionReadCommand.fullPartitionRead(cfm, nowInSec, dk);
EndpointsForToken targetReplicas = EndpointsForToken.of(dk.getToken(), full(EP1), full(EP2));
DigestResolver resolver = new DigestResolver(command, plan(ConsistencyLevel.QUORUM, targetReplicas), 0);
PartitionUpdate response = update(row(1000, 4, 4), row(1000, 5, 5)).build();
Assert.assertFalse(resolver.isDataPresent());
resolver.preprocess(response(command, EP2, iter(response), true));
resolver.preprocess(response(command, EP1, iter(response), false));
Assert.assertTrue(resolver.isDataPresent());
Assert.assertTrue(resolver.responsesMatch());
assertPartitionsEqual(filter(iter(response)), resolver.getData());
}
use of org.apache.cassandra.db.SinglePartitionReadCommand 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());
}
Aggregations