use of com.palantir.atlasdb.internalschema.TransactionSchemaManager in project atlasdb by palantir.
the class TransactionManagers method getTransactionSchemaInstallerIfSupported.
private static Optional<TransactionSchemaInstaller> getTransactionSchemaInstallerIfSupported(@Output List<AutoCloseable> closeables, KeyValueService keyValueService, Supplier<AtlasDbRuntimeConfig> runtimeConfigSupplier, TransactionSchemaManager transactionSchemaManager) {
CheckAndSetCompatibility compatibility = keyValueService.getCheckAndSetCompatibility();
if (compatibility.supportsCheckAndSetOperations() && compatibility.supportsDetailOnFailure()) {
return Optional.of(initializeTransactionSchemaInstaller(closeables, runtimeConfigSupplier, transactionSchemaManager));
}
runtimeConfigSupplier.get().internalSchema().targetTransactionsSchemaVersion().filter(version -> version != TransactionConstants.DIRECT_ENCODING_TRANSACTIONS_SCHEMA_VERSION).ifPresent(version -> log.warn("This service seems like it has been configured to use transaction schema version {}," + " which isn't supported as your KVS doesn't support details on CAS failures" + " (typically Postgres or Oracle). We will remain with transactions1.", SafeArg.of("configuredTransactionSchemaVersion", version)));
return Optional.empty();
}
use of com.palantir.atlasdb.internalschema.TransactionSchemaManager 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();
}
use of com.palantir.atlasdb.internalschema.TransactionSchemaManager in project atlasdb by palantir.
the class TransactionServicesTest method forceInstallV2.
private void forceInstallV2() {
TransactionSchemaManager transactionSchemaManager = new TransactionSchemaManager(coordinationService);
Awaitility.await().atMost(Duration.ofSeconds(10)).until(() -> {
transactionSchemaManager.tryInstallNewTransactionsSchemaVersion(2);
((TimestampManagementService) timestampService).fastForwardTimestamp(timestampService.getFreshTimestamp() + 1_000_000);
return transactionSchemaManager.getTransactionsSchemaVersion(timestampService.getFreshTimestamp()) == 2;
});
}
use of com.palantir.atlasdb.internalschema.TransactionSchemaManager 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();
}
use of com.palantir.atlasdb.internalschema.TransactionSchemaManager 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