Search in sources :

Example 6 with InternalSchemaMetadata

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))));
}
Also used : InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) ImmutableRangeMap(com.google.common.collect.ImmutableRangeMap)

Example 7 with InternalSchemaMetadata

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);
}
Also used : FullyBoundedTimestampRange(com.palantir.timestamp.FullyBoundedTimestampRange) InternalSchemaMetadataState(com.palantir.atlasdb.internalschema.InternalSchemaMetadataState) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) Test(org.junit.Test)

Example 8 with InternalSchemaMetadata

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);
}
Also used : TransactionSchemaManager(com.palantir.atlasdb.internalschema.TransactionSchemaManager) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata)

Aggregations

InternalSchemaMetadata (com.palantir.atlasdb.internalschema.InternalSchemaMetadata)8 TransactionSchemaManager (com.palantir.atlasdb.internalschema.TransactionSchemaManager)3 Test (org.junit.Test)3 InternalSchemaMetadataState (com.palantir.atlasdb.internalschema.InternalSchemaMetadataState)2 ImmutableRangeMap (com.google.common.collect.ImmutableRangeMap)1 ReadOnlyTransactionSchemaManager (com.palantir.atlasdb.internalschema.ReadOnlyTransactionSchemaManager)1 TransactionSchemaInstaller (com.palantir.atlasdb.internalschema.TransactionSchemaInstaller)1 TransactionService (com.palantir.atlasdb.transaction.service.TransactionService)1 MetricsManager (com.palantir.atlasdb.util.MetricsManager)1 SafeIllegalStateException (com.palantir.logsafe.exceptions.SafeIllegalStateException)1 FullyBoundedTimestampRange (com.palantir.timestamp.FullyBoundedTimestampRange)1 TimestampService (com.palantir.timestamp.TimestampService)1 Before (org.junit.Before)1