use of org.apache.cassandra.db.rows.RangeTombstoneBoundMarker in project cassandra by apache.
the class JsonTransformer method serializeTombstone.
private void serializeTombstone(RangeTombstoneMarker tombstone) {
try {
json.writeStartObject();
json.writeFieldName("type");
if (tombstone instanceof RangeTombstoneBoundMarker) {
json.writeString("range_tombstone_bound");
RangeTombstoneBoundMarker bm = (RangeTombstoneBoundMarker) tombstone;
serializeBound(bm.clustering(), bm.deletionTime());
} else {
assert tombstone instanceof RangeTombstoneBoundaryMarker;
json.writeString("range_tombstone_boundary");
RangeTombstoneBoundaryMarker bm = (RangeTombstoneBoundaryMarker) tombstone;
serializeBound(bm.openBound(false), bm.openDeletionTime(false));
serializeBound(bm.closeBound(false), bm.closeDeletionTime(false));
}
json.writeEndObject();
objectIndenter.setCompact(false);
} catch (IOException e) {
logger.error("Failure parsing tombstone.", e);
}
}
use of org.apache.cassandra.db.rows.RangeTombstoneBoundMarker in project cassandra by apache.
the class DataResolverTest method testRepairRangeTombstoneBoundary.
/**
* Test for CASSANDRA-13237, checking we don't fail (and handle correctly) the case where a RT boundary has the
* same deletion on both side (while is useless but could be created by legacy code pre-CASSANDRA-13237 and could
* thus still be sent).
*/
private void testRepairRangeTombstoneBoundary(int timestamp1, int timestamp2, int timestamp3) throws UnknownHostException {
EndpointsForRange replicas = makeReplicas(2);
DataResolver resolver = new DataResolver(command, plan(replicas, ALL), readRepair, nanoTime());
InetAddressAndPort peer1 = replicas.get(0).endpoint();
InetAddressAndPort peer2 = replicas.get(1).endpoint();
// 1st "stream"
RangeTombstone one_nine = tombstone("0", true, "9", true, timestamp1, nowInSec);
UnfilteredPartitionIterator iter1 = iter(new RowUpdateBuilder(cfm, nowInSec, 1L, dk).addRangeTombstone(one_nine).buildUpdate());
// 2nd "stream" (build more manually to ensure we have the boundary we want)
RangeTombstoneBoundMarker open_one = marker("0", true, true, timestamp2, nowInSec);
RangeTombstoneBoundaryMarker boundary_five = boundary("5", false, timestamp2, nowInSec, timestamp3, nowInSec);
RangeTombstoneBoundMarker close_nine = marker("9", false, true, timestamp3, nowInSec);
UnfilteredPartitionIterator iter2 = iter(dk, open_one, boundary_five, close_nine);
resolver.preprocess(response(command, peer1, iter1));
resolver.preprocess(response(command, peer2, iter2));
boolean shouldHaveRepair = timestamp1 != timestamp2 || timestamp1 != timestamp3;
// No results, we've only reconciled tombstones.
try (PartitionIterator data = resolver.resolve()) {
assertFalse(data.hasNext());
}
assertEquals(shouldHaveRepair ? 1 : 0, readRepair.sent.size());
if (!shouldHaveRepair)
return;
Mutation mutation = readRepair.getForEndpoint(peer2);
assertRepairMetadata(mutation);
assertRepairContainsNoColumns(mutation);
RangeTombstone expected = timestamp1 != timestamp2 ? // We've repaired the 1st part
tombstone("0", true, "5", false, timestamp1, nowInSec) : // We've repaired the 2nd part
tombstone("5", true, "9", true, timestamp1, nowInSec);
assertRepairContainsDeletions(mutation, null, expected);
}
Aggregations