use of com.palantir.timestamp.FullyBoundedTimestampRange in project atlasdb by palantir.
the class AtlasRestoreService method repairTransactionsTables.
private void repairTransactionsTables(RestoreRequest restoreRequest, CompletedBackup completedBackup, BiConsumer<String, RangesForRepair> repairTable) {
Map<FullyBoundedTimestampRange, Integer> coordinationMap = getCoordinationMap(restoreRequest.oldAtlasService(), completedBackup);
List<TransactionsTableInteraction> transactionsTableInteractions = TransactionsTableInteraction.getTransactionTableInteractions(coordinationMap, DefaultRetryPolicy.INSTANCE);
AtlasService atlasService = restoreRequest.newAtlasService();
cassandraRepairHelper.repairTransactionsTables(atlasService, transactionsTableInteractions, repairTable);
cassandraRepairHelper.cleanTransactionsTables(atlasService, completedBackup.getBackupStartTimestamp(), transactionsTableInteractions);
}
use of com.palantir.timestamp.FullyBoundedTimestampRange in project atlasdb by palantir.
the class TransactionAborterTest method setupAbortTimestampTask.
private void setupAbortTimestampTask(ImmutableList<TransactionTableEntry> entries, FullyBoundedTimestampRange range) {
when(transactionInteraction.getTimestampRange()).thenReturn(range);
List<Row> rows = entries.stream().map(entry -> {
Row row = mock(Row.class);
when(transactionInteraction.extractTimestamps(row)).thenReturn(entry);
return row;
}).collect(Collectors.toList());
ResultSet selectResponse = createSelectResponse(rows);
when(transactionInteraction.createSelectStatementsForScanningFullTimestampRange(any())).thenReturn(ImmutableList.of(mock(Statement.class)));
when(cqlSession.execute(any(Statement.class))).thenReturn(selectResponse);
}
use of com.palantir.timestamp.FullyBoundedTimestampRange in project atlasdb by palantir.
the class CoordinationServiceUtilitiesTest method correctlyBoundsTimestampsForRestore.
// During restores, we need to clean transactions tables in between two timestamps.
// It's possible that, in between _those_ timestamps, AtlasDB changed which transactions
// table to use. This is recorded in InternalSchemaMetadata.
//
// In this test, we simulate a switch from transactions1 to transactions2 at timestamp 10
// We should return the [5-10] range for transactions1, and the (10-15] range for transactions2.
@Test
public void correctlyBoundsTimestampsForRestore() {
long lowerBoundForRestore = 5L;
long maxTimestampForTransactions1 = 10L;
long upperBoundForRestore = 15L;
RangeMap<Long, Integer> rangeMap = ImmutableRangeMap.<Long, Integer>builder().put(Range.closed(1L, maxTimestampForTransactions1), 1).put(Range.greaterThan(maxTimestampForTransactions1), 2).build();
TimestampPartitioningMap<Integer> timestampsMap = TimestampPartitioningMap.of(rangeMap);
InternalSchemaMetadata metadata = InternalSchemaMetadata.builder().timestampToTransactionsTableSchemaVersion(timestampsMap).build();
ValueAndBound<InternalSchemaMetadata> value = ValueAndBound.of(metadata, 1000L);
InternalSchemaMetadataState state = InternalSchemaMetadataState.of(value);
Map<FullyBoundedTimestampRange, Integer> boundedMap = CoordinationServiceUtilities.getCoordinationMapOnRestore(Optional.of(state), upperBoundForRestore, lowerBoundForRestore);
Map<FullyBoundedTimestampRange, Integer> expected = ImmutableMap.of(FullyBoundedTimestampRange.of(Range.closed(lowerBoundForRestore, maxTimestampForTransactions1)), 1, FullyBoundedTimestampRange.of(Range.openClosed(maxTimestampForTransactions1, upperBoundForRestore)), 2);
assertThat(boundedMap).hasSize(2);
assertThat(boundedMap).containsExactlyInAnyOrderEntriesOf(expected);
}
Aggregations