Search in sources :

Example 1 with CheckAndSetCompatibility

use of com.palantir.atlasdb.keyvalue.api.CheckAndSetCompatibility 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();
}
Also used : TransactionService(com.palantir.atlasdb.transaction.service.TransactionService) NoOpBackgroundSweeperPerformanceLogger(com.palantir.atlasdb.sweep.NoOpBackgroundSweeperPerformanceLogger) SafeTableClearerKeyValueService(com.palantir.atlasdb.sweep.queue.clear.SafeTableClearerKeyValueService) SharedResourcesConfig(com.palantir.atlasdb.spi.SharedResourcesConfig) TimelockTimestampServiceAdapter(com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter) KeyValueServicePuncherStore(com.palantir.atlasdb.cleaner.KeyValueServicePuncherStore) TargetedSweepTableFactory(com.palantir.atlasdb.schema.generated.TargetedSweepTableFactory) LockServerOptions(com.palantir.lock.LockServerOptions) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) GlobalClock(com.palantir.atlasdb.cleaner.GlobalClock) TimeLockRequestBatcherProviders(com.palantir.atlasdb.config.TimeLockRequestBatcherProviders) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) CoordinationServices(com.palantir.atlasdb.internalschema.persistence.CoordinationServices) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) AtlasDbConstants(com.palantir.atlasdb.AtlasDbConstants) Refreshable(com.palantir.refreshable.Refreshable) SweeperServiceImpl(com.palantir.atlasdb.sweep.SweeperServiceImpl) ConflictDetectionManagers(com.palantir.atlasdb.transaction.impl.ConflictDetectionManagers) NamedThreadFactory(com.palantir.common.concurrent.NamedThreadFactory) TargetedSweepRuntimeConfig(com.palantir.atlasdb.sweep.queue.config.TargetedSweepRuntimeConfig) TargetedSweepSchema(com.palantir.atlasdb.schema.TargetedSweepSchema) TimeLockFeedbackBackgroundTask(com.palantir.lock.client.metrics.TimeLockFeedbackBackgroundTask) Set(java.util.Set) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) MetricsManagers(com.palantir.atlasdb.util.MetricsManagers) SweepBatchConfig(com.palantir.atlasdb.sweep.SweepBatchConfig) ServicesConfigBlock(com.palantir.conjure.java.api.config.service.ServicesConfigBlock) KvsProfilingLogger(com.palantir.atlasdb.logging.KvsProfilingLogger) Stream(java.util.stream.Stream) MetricsFilterEvaluationContext(com.palantir.atlasdb.transaction.impl.metrics.MetricsFilterEvaluationContext) KeyValueServiceConfig(com.palantir.atlasdb.spi.KeyValueServiceConfig) ImmutableTimestampCorroborationConsistencyCheck(com.palantir.atlasdb.transaction.impl.consistency.ImmutableTimestampCorroborationConsistencyCheck) DefaultMetricsFilterEvaluationContext(com.palantir.atlasdb.transaction.impl.metrics.DefaultMetricsFilterEvaluationContext) SweepStatsKeyValueService(com.palantir.atlasdb.keyvalue.impl.SweepStatsKeyValueService) TimeLockClientConfig(com.palantir.atlasdb.config.TimeLockClientConfig) SimpleTimeDuration(com.palantir.lock.SimpleTimeDuration) LockServiceImpl(com.palantir.lock.impl.LockServiceImpl) AsyncInitializer(com.palantir.async.initializer.AsyncInitializer) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ValidatingQueryRewritingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ValidatingQueryRewritingKeyValueService) AtlasDbVersion(com.palantir.atlasdb.versions.AtlasDbVersion) CompactorConfig(com.palantir.atlasdb.compact.CompactorConfig) ImmutableSweepBatchConfig(com.palantir.atlasdb.sweep.ImmutableSweepBatchConfig) BackgroundCompactor(com.palantir.atlasdb.compact.BackgroundCompactor) LockRequest(com.palantir.lock.LockRequest) MetadataCoordinationServiceMetrics(com.palantir.atlasdb.internalschema.metrics.MetadataCoordinationServiceMetrics) TargetedSweepInstallConfig(com.palantir.atlasdb.sweep.queue.config.TargetedSweepInstallConfig) LockServerConfigs(com.palantir.lock.LockServerConfigs) SweepConfig(com.palantir.atlasdb.config.SweepConfig) Clock(com.palantir.common.time.Clock) MetricRegistry(com.codahale.metrics.MetricRegistry) Callback(com.palantir.async.initializer.Callback) TargetedSweeper(com.palantir.atlasdb.sweep.queue.TargetedSweeper) TransactionSchemaManager(com.palantir.atlasdb.internalschema.TransactionSchemaManager) TransactionSchemaInstaller(com.palantir.atlasdb.internalschema.TransactionSchemaInstaller) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) SweepTableFactory(com.palantir.atlasdb.schema.generated.SweepTableFactory) BackgroundSweeperImpl(com.palantir.atlasdb.sweep.BackgroundSweeperImpl) Follower(com.palantir.atlasdb.cleaner.Follower) LockService(com.palantir.lock.LockService) TimeLockClient(com.palantir.lock.client.TimeLockClient) ManagedTimestampService(com.palantir.timestamp.ManagedTimestampService) UserAgents(com.palantir.conjure.java.api.config.service.UserAgents) LockClient(com.palantir.lock.LockClient) MultiTableSweepQueueWriter(com.palantir.atlasdb.sweep.queue.MultiTableSweepQueueWriter) ConflictTracer(com.palantir.atlasdb.debug.ConflictTracer) ConflictDetectionManager(com.palantir.atlasdb.transaction.impl.ConflictDetectionManager) ShouldRunBackgroundSweepSupplier(com.palantir.atlasdb.config.ShouldRunBackgroundSweepSupplier) DerivedSnapshotConfig(com.palantir.atlasdb.spi.DerivedSnapshotConfig) SweepStrategyManager(com.palantir.atlasdb.transaction.impl.SweepStrategyManager) StagedBuilderStyle(com.palantir.common.annotations.ImmutablesStyles.StagedBuilderStyle) LockRefreshingLockService(com.palantir.lock.client.LockRefreshingLockService) TimeLockClientFeedbackService(com.palantir.atlasdb.timelock.adjudicate.feedback.TimeLockClientFeedbackService) CheckAndSetCompatibility(com.palantir.atlasdb.keyvalue.api.CheckAndSetCompatibility) TransactionConfig(com.palantir.atlasdb.transaction.TransactionConfig) MetricsManager(com.palantir.atlasdb.util.MetricsManager) PTExecutors(com.palantir.common.concurrent.PTExecutors) TransactionServices(com.palantir.atlasdb.transaction.service.TransactionServices) LockWatchingCache(com.palantir.atlasdb.transaction.api.LockWatchingCache) SweepTaskRunner(com.palantir.atlasdb.sweep.SweepTaskRunner) ToLongFunction(java.util.function.ToLongFunction) ImmutableSet(com.google.common.collect.ImmutableSet) CoordinationService(com.palantir.atlasdb.coordination.CoordinationService) LockDiagnosticComponents(com.palantir.atlasdb.debug.LockDiagnosticComponents) DefaultCleanerBuilder(com.palantir.atlasdb.cleaner.DefaultCleanerBuilder) ProfilingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ProfilingKeyValueService) Collectors(java.util.stream.Collectors) ServerListConfig(com.palantir.atlasdb.config.ServerListConfig) AtlasDbMetricNames(com.palantir.atlasdb.AtlasDbMetricNames) List(java.util.List) Optional(java.util.Optional) ConsistencyCheckRunner(com.palantir.atlasdb.factory.startup.ConsistencyCheckRunner) SafeLoggerFactory(com.palantir.logsafe.logger.SafeLoggerFactory) Cleaner(com.palantir.atlasdb.cleaner.api.Cleaner) AtlasDbMetrics(com.palantir.atlasdb.util.AtlasDbMetrics) Output(com.palantir.common.annotation.Output) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) TimestampStoreInvalidator(com.palantir.timestamp.TimestampStoreInvalidator) AdjustableSweepBatchConfigSource(com.palantir.atlasdb.sweep.AdjustableSweepBatchConfigSource) Function(java.util.function.Function) SafeLogger(com.palantir.logsafe.logger.SafeLogger) AtlasDbConstraintCheckingMode(com.palantir.atlasdb.transaction.api.AtlasDbConstraintCheckingMode) SafeArg(com.palantir.logsafe.SafeArg) ImmutableList(com.google.common.collect.ImmutableList) Value(org.immutables.value.Value) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) AuxiliaryRemotingParameters(com.palantir.atlasdb.config.AuxiliaryRemotingParameters) TracingKeyValueService(com.palantir.atlasdb.keyvalue.impl.TracingKeyValueService) ImmutableTransactionConfig(com.palantir.atlasdb.transaction.ImmutableTransactionConfig) FreshTimestampSupplierAdapter(com.palantir.atlasdb.factory.timestamp.FreshTimestampSupplierAdapter) SweepStrategyManagers(com.palantir.atlasdb.transaction.impl.SweepStrategyManagers) BackgroundSweeperPerformanceLogger(com.palantir.atlasdb.sweep.BackgroundSweeperPerformanceLogger) NoOpLockWatchingCache(com.palantir.atlasdb.transaction.api.NoOpLockWatchingCache) TimestampCache(com.palantir.atlasdb.cache.TimestampCache) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) LambdaCallback(com.palantir.async.initializer.LambdaCallback) TransactionConstants(com.palantir.atlasdb.transaction.impl.TransactionConstants) SpecificTableSweeper(com.palantir.atlasdb.sweep.SpecificTableSweeper) LegacySweepMetrics(com.palantir.atlasdb.sweep.metrics.LegacySweepMetrics) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) AtlasDbRemotingConstants(com.palantir.atlasdb.http.AtlasDbRemotingConstants) CellsSweeper(com.palantir.atlasdb.sweep.CellsSweeper) VisibleForTesting(com.google.common.annotations.VisibleForTesting) DefaultTimestampCache(com.palantir.atlasdb.cache.DefaultTimestampCache) DialogueClients(com.palantir.dialogue.clients.DialogueClients) OldestTargetedSweepTrackedTimestamp(com.palantir.atlasdb.sweep.queue.OldestTargetedSweepTrackedTimestamp) Schema(com.palantir.atlasdb.table.description.Schema) Preconditions(com.palantir.logsafe.Preconditions) CleanupFollower(com.palantir.atlasdb.cleaner.CleanupFollower) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) CheckAndSetCompatibility(com.palantir.atlasdb.keyvalue.api.CheckAndSetCompatibility)

Example 2 with CheckAndSetCompatibility

use of com.palantir.atlasdb.keyvalue.api.CheckAndSetCompatibility in project atlasdb by palantir.

the class DualWriteKeyValueServiceTest method checkAndSetCompatibilityIsBasedOnTheFirstDelegate.

@Test
public void checkAndSetCompatibilityIsBasedOnTheFirstDelegate() {
    CheckAndSetCompatibility firstDelegateCompatibility = CheckAndSetCompatibility.supportedBuilder().supportsDetailOnFailure(true).consistentOnFailure(false).build();
    when(delegate1.getCheckAndSetCompatibility()).thenReturn(firstDelegateCompatibility);
    when(delegate2.getCheckAndSetCompatibility()).thenReturn(CheckAndSetCompatibility.unsupported());
    assertThat(dualWriteService.getCheckAndSetCompatibility()).isEqualTo(firstDelegateCompatibility);
    verify(delegate1).getCheckAndSetCompatibility();
    verifyNoMoreInteractions(delegate1, delegate2);
}
Also used : CheckAndSetCompatibility(com.palantir.atlasdb.keyvalue.api.CheckAndSetCompatibility) Test(org.junit.Test)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)1 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 AsyncInitializer (com.palantir.async.initializer.AsyncInitializer)1 Callback (com.palantir.async.initializer.Callback)1 LambdaCallback (com.palantir.async.initializer.LambdaCallback)1 AtlasDbConstants (com.palantir.atlasdb.AtlasDbConstants)1 AtlasDbMetricNames (com.palantir.atlasdb.AtlasDbMetricNames)1 DefaultTimestampCache (com.palantir.atlasdb.cache.DefaultTimestampCache)1 TimestampCache (com.palantir.atlasdb.cache.TimestampCache)1 CleanupFollower (com.palantir.atlasdb.cleaner.CleanupFollower)1 DefaultCleanerBuilder (com.palantir.atlasdb.cleaner.DefaultCleanerBuilder)1 Follower (com.palantir.atlasdb.cleaner.Follower)1 GlobalClock (com.palantir.atlasdb.cleaner.GlobalClock)1 KeyValueServicePuncherStore (com.palantir.atlasdb.cleaner.KeyValueServicePuncherStore)1 Cleaner (com.palantir.atlasdb.cleaner.api.Cleaner)1 BackgroundCompactor (com.palantir.atlasdb.compact.BackgroundCompactor)1 CompactorConfig (com.palantir.atlasdb.compact.CompactorConfig)1