use of com.palantir.atlasdb.internalschema.InternalSchemaMetadata in project atlasdb by palantir.
the class CoordinationServiceUtilitiesTest method createCoordService.
private static Optional<InternalSchemaMetadataState> createCoordService(Map<Range<Long>, Integer> rangesWithSchemas, long bound) {
ImmutableRangeMap.Builder<Long, Integer> rangeMapBuilder = ImmutableRangeMap.builder();
rangesWithSchemas.forEach(rangeMapBuilder::put);
RangeMap<Long, Integer> rangeMap = rangeMapBuilder.build();
InternalSchemaMetadata internalSchemaMetadata = InternalSchemaMetadata.builder().timestampToTransactionsTableSchemaVersion(TimestampPartitioningMap.of(rangeMap)).build();
return Optional.of(InternalSchemaMetadataState.of(Optional.of(ValueAndBound.of(internalSchemaMetadata, bound))));
}
use of com.palantir.atlasdb.internalschema.InternalSchemaMetadata 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);
}
use of com.palantir.atlasdb.internalschema.InternalSchemaMetadata in project atlasdb by palantir.
the class AtlasDbEteServer method ensureTransactionSchemaVersionInstalled.
private void ensureTransactionSchemaVersionInstalled(AtlasDbConfig config, Optional<AtlasDbRuntimeConfig> runtimeConfig, TransactionManager transactionManager) {
if (runtimeConfig.isEmpty() || runtimeConfig.get().internalSchema().targetTransactionsSchemaVersion().isEmpty()) {
return;
}
CoordinationService<InternalSchemaMetadata> coordinationService = CoordinationServices.createDefault(transactionManager.getKeyValueService(), transactionManager.getTimestampService(), MetricsManagers.createForTests(), config.initializeAsync());
TransactionSchemaManager manager = new TransactionSchemaManager(coordinationService);
int targetSchemaVersion = runtimeConfig.get().internalSchema().targetTransactionsSchemaVersion().get();
TransactionSchemaVersionEnforcement.ensureTransactionsGoingForwardHaveSchemaVersion(manager, transactionManager.getTimestampService(), transactionManager.getTimestampManagementService(), targetSchemaVersion);
}
Aggregations