Search in sources :

Example 1 with InternalSchemaMetadata

use of com.palantir.atlasdb.internalschema.InternalSchemaMetadata in project atlasdb by palantir.

the class TransactionManagers method createTransactionComponents.

private TransactionComponents createTransactionComponents(@Output List<AutoCloseable> closeables, MetricsManager metricsManager, LockAndTimestampServices lockAndTimestampServices, KeyValueService keyValueService, Supplier<AtlasDbRuntimeConfig> runtimeConfigSupplier) {
    CoordinationService<InternalSchemaMetadata> coordinationService = getSchemaMetadataCoordinationService(metricsManager, lockAndTimestampServices, keyValueService);
    TransactionSchemaManager transactionSchemaManager = new TransactionSchemaManager(coordinationService);
    TransactionService transactionService = initializeCloseable(() -> AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), TransactionService.class, TransactionServices.createTransactionService(keyValueService, transactionSchemaManager, metricsManager.getTaggedRegistry(), () -> runtimeConfigSupplier.get().internalSchema().acceptStagingReadsOnVersionThree())), closeables);
    Optional<TransactionSchemaInstaller> schemaInstaller = getTransactionSchemaInstallerIfSupported(closeables, keyValueService, runtimeConfigSupplier, transactionSchemaManager);
    return ImmutableTransactionComponents.builder().transactionService(transactionService).schemaInstaller(schemaInstaller).build();
}
Also used : TransactionSchemaManager(com.palantir.atlasdb.internalschema.TransactionSchemaManager) TransactionService(com.palantir.atlasdb.transaction.service.TransactionService) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) TransactionSchemaInstaller(com.palantir.atlasdb.internalschema.TransactionSchemaInstaller)

Example 2 with InternalSchemaMetadata

use of com.palantir.atlasdb.internalschema.InternalSchemaMetadata in project atlasdb by palantir.

the class MetadataCoordinationServiceMetricsTest method handlesMultitenancyCorrectly.

@Test
public void handlesMultitenancyCorrectly() {
    CoordinationService<InternalSchemaMetadata> otherService = mock(CoordinationService.class);
    MetricsManager otherManager = MetricsManagers.createForTests();
    TimestampService otherTimestampService = mock(TimestampService.class);
    MetadataCoordinationServiceMetrics.registerMetrics(otherManager, otherService, otherTimestampService);
    when(otherService.getLastKnownLocalValue()).thenReturn(Optional.of(ValueAndBound.of(Optional.empty(), TIMESTAMP_2)));
    assertThat(getGauge(metricsManager, AtlasDbMetricNames.COORDINATION_LAST_VALID_BOUND).getValue()).isEqualTo(TIMESTAMP_1);
    assertThat(getGauge(otherManager, AtlasDbMetricNames.COORDINATION_LAST_VALID_BOUND).getValue()).isEqualTo(TIMESTAMP_2);
}
Also used : InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) MetricsManager(com.palantir.atlasdb.util.MetricsManager) TimestampService(com.palantir.timestamp.TimestampService) Test(org.junit.Test)

Example 3 with InternalSchemaMetadata

use of com.palantir.atlasdb.internalschema.InternalSchemaMetadata in project atlasdb by palantir.

the class TransactionServices method createReadOnlyTransactionServiceIgnoresUncommittedTransactionsDoesNotRollBack.

public static TransactionService createReadOnlyTransactionServiceIgnoresUncommittedTransactionsDoesNotRollBack(KeyValueService keyValueService, MetricsManager metricsManager) {
    if (keyValueService.supportsCheckAndSet()) {
        CoordinationService<InternalSchemaMetadata> coordinationService = CoordinationServices.createDefault(keyValueService, () -> {
            throw new SafeIllegalStateException("Attempted to get a timestamp from a read-only" + " transaction service! This is probably a product bug. Please contact" + " support.");
        }, metricsManager, false);
        ReadOnlyTransactionSchemaManager readOnlyTransactionSchemaManager = new ReadOnlyTransactionSchemaManager(coordinationService);
        return new PreStartHandlingTransactionService(new SplitKeyDelegatingTransactionService<>(readOnlyTransactionSchemaManager::getTransactionsSchemaVersion, ImmutableMap.of(1, createV1TransactionService(keyValueService))));
    }
    return createV1TransactionService(keyValueService);
}
Also used : InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) ReadOnlyTransactionSchemaManager(com.palantir.atlasdb.internalschema.ReadOnlyTransactionSchemaManager) SafeIllegalStateException(com.palantir.logsafe.exceptions.SafeIllegalStateException)

Example 4 with InternalSchemaMetadata

use of com.palantir.atlasdb.internalschema.InternalSchemaMetadata in project atlasdb by palantir.

the class ExternalBackupPersisterTest method putAndGetSchemaMetadata.

@Test
public void putAndGetSchemaMetadata() {
    InternalSchemaMetadata internalSchemaMetadata = InternalSchemaMetadata.defaultValue();
    InternalSchemaMetadataState state = InternalSchemaMetadataState.of(ValueAndBound.of(internalSchemaMetadata, 100L));
    externalBackupPersister.storeSchemaMetadata(ATLAS_SERVICE, state);
    assertThat(externalBackupPersister.getSchemaMetadata(ATLAS_SERVICE)).contains(state);
}
Also used : InternalSchemaMetadataState(com.palantir.atlasdb.internalschema.InternalSchemaMetadataState) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) Test(org.junit.Test)

Example 5 with InternalSchemaMetadata

use of com.palantir.atlasdb.internalschema.InternalSchemaMetadata in project atlasdb by palantir.

the class TransactionTestSetup method setUp.

@Before
public void setUp() {
    timestampCache = ComparingTimestampCache.comparingOffHeapForTests(metricsManager, persistentStore);
    lockService = LockServiceImpl.create(LockServerOptions.builder().isStandaloneServer(false).build());
    lockClient = LockClient.of("test_client");
    keyValueService = getKeyValueService();
    keyValueService.createTables(ImmutableMap.of(TEST_TABLE_THOROUGH, TableMetadata.builder().rangeScanAllowed(true).explicitCompressionBlockSizeKB(4).negativeLookups(true).sweepStrategy(SweepStrategy.THOROUGH).build().persistToBytes(), TEST_TABLE, TableMetadata.builder().rangeScanAllowed(true).explicitCompressionBlockSizeKB(4).negativeLookups(true).sweepStrategy(SweepStrategy.NOTHING).build().persistToBytes(), TEST_TABLE_SERIALIZABLE, TableMetadata.builder().rangeScanAllowed(true).explicitCompressionBlockSizeKB(4).negativeLookups(true).conflictHandler(ConflictHandler.SERIALIZABLE).sweepStrategy(SweepStrategy.NOTHING).build().persistToBytes()));
    TransactionTables.createTables(keyValueService);
    TransactionTables.truncateTables(keyValueService);
    keyValueService.truncateTable(TEST_TABLE);
    keyValueService.truncateTable(TEST_TABLE_SERIALIZABLE);
    timestampService = inMemoryTimeLockRule.getTimestampService();
    timestampManagementService = inMemoryTimeLockRule.getTimestampManagementService();
    timelockService = inMemoryTimeLockRule.getLegacyTimelockService();
    lockWatchManager = inMemoryTimeLockRule.getLockWatchManager();
    CoordinationService<InternalSchemaMetadata> coordinationService = CoordinationServices.createDefault(keyValueService, timestampService, metricsManager, false);
    transactionSchemaManager = new TransactionSchemaManager(coordinationService);
    transactionService = createTransactionService(keyValueService, transactionSchemaManager);
    conflictDetectionManager = ConflictDetectionManagers.createWithoutWarmingCache(keyValueService);
    sweepStrategyManager = SweepStrategyManagers.createDefault(keyValueService);
    txMgr = createAndRegisterManager();
}
Also used : TransactionSchemaManager(com.palantir.atlasdb.internalschema.TransactionSchemaManager) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) Before(org.junit.Before)

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