Search in sources :

Example 1 with DefaultTimestampCache

use of com.palantir.atlasdb.cache.DefaultTimestampCache in project atlasdb by palantir.

the class ComparingTimestampCache method comparingOffHeapForTests.

public static TimestampCache comparingOffHeapForTests(MetricsManager metricRegistry, PersistentStore persistentStore) {
    TimestampCache first = new DefaultTimestampCache(metricRegistry.getRegistry(), () -> AtlasDbConstants.DEFAULT_TIMESTAMP_CACHE_SIZE);
    TimestampCache second = OffHeapTimestampCache.create(persistentStore, metricRegistry.getTaggedRegistry(), () -> AtlasDbConstants.DEFAULT_TIMESTAMP_CACHE_SIZE);
    return new ComparingTimestampCache(first, second);
}
Also used : DefaultTimestampCache(com.palantir.atlasdb.cache.DefaultTimestampCache) TimestampCache(com.palantir.atlasdb.cache.TimestampCache) OffHeapTimestampCache(com.palantir.atlasdb.cache.OffHeapTimestampCache) DefaultTimestampCache(com.palantir.atlasdb.cache.DefaultTimestampCache)

Example 2 with DefaultTimestampCache

use of com.palantir.atlasdb.cache.DefaultTimestampCache in project atlasdb by palantir.

the class TransactionManagers method serializableInternal.

@SuppressWarnings("MethodLength")
private TransactionManager serializableInternal(@Output List<AutoCloseable> closeables) {
    MetricsManager metricsManager = setUpMetricsAndGetMetricsManager();
    AtlasDbRuntimeConfigRefreshable runtimeConfigRefreshable = initializeCloseable(() -> AtlasDbRuntimeConfigRefreshable.create(this), closeables);
    Refreshable<AtlasDbRuntimeConfig> runtime = runtimeConfigRefreshable.config();
    Optional<TimeLockFeedbackBackgroundTask> timeLockFeedbackBackgroundTask = getTimeLockFeedbackBackgroundTask(metricsManager, closeables, config(), runtime);
    FreshTimestampSupplierAdapter adapter = new FreshTimestampSupplierAdapter();
    KeyValueServiceConfig installConfig = config().keyValueService();
    ServiceDiscoveringAtlasSupplier atlasFactory = new ServiceDiscoveringAtlasSupplier(metricsManager, installConfig, runtime.map(AtlasDbRuntimeConfig::keyValueService), config().leader(), config().namespace(), Optional.empty(), config().initializeAsync(), adapter);
    DerivedSnapshotConfig derivedSnapshotConfig = atlasFactory.getDerivedSnapshotConfig();
    LockRequest.setDefaultLockTimeout(SimpleTimeDuration.of(config().getDefaultLockTimeoutSeconds(), TimeUnit.SECONDS));
    LockAndTimestampServiceFactory factory = lockAndTimestampServiceFactory().orElseGet(() -> new DefaultLockAndTimestampServiceFactory(metricsManager, config(), runtime, registrar(), () -> LockServiceImpl.create(lockServerOptions()), atlasFactory::getManagedTimestampService, atlasFactory.getTimestampStoreInvalidator(), userAgent(), lockDiagnosticComponents(), reloadingFactory(), timeLockFeedbackBackgroundTask, timelockRequestBatcherProviders(), schemas()));
    LockAndTimestampServices lockAndTimestampServices = factory.createLockAndTimestampServices();
    adapter.setTimestampService(lockAndTimestampServices.managedTimestampService());
    KvsProfilingLogger.setSlowLogThresholdMillis(config().getKvsSlowLogThresholdMillis());
    Refreshable<SweepConfig> sweepConfig = runtime.map(AtlasDbRuntimeConfig::sweep);
    KeyValueService keyValueService = initializeCloseable(() -> {
        KeyValueService kvs = atlasFactory.getKeyValueService();
        kvs = ProfilingKeyValueService.create(kvs);
        kvs = new SafeTableClearerKeyValueService(lockAndTimestampServices.timelock()::getImmutableTimestamp, kvs);
        // table.
        if (!targetedSweepIsFullyEnabled(config(), runtime)) {
            kvs = SweepStatsKeyValueService.create(kvs, new TimelockTimestampServiceAdapter(lockAndTimestampServices.timelock()), sweepConfig.map(SweepConfig::writeThreshold), sweepConfig.map(SweepConfig::writeSizeThreshold), () -> true);
        }
        kvs = TracingKeyValueService.create(kvs);
        kvs = AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), KeyValueService.class, kvs, MetricRegistry.name(KeyValueService.class));
        return ValidatingQueryRewritingKeyValueService.create(kvs);
    }, closeables);
    if (config().targetedSweep().enableSweepQueueWrites()) {
        initializeCloseable(() -> OldestTargetedSweepTrackedTimestamp.createStarted(keyValueService, lockAndTimestampServices.timestamp(), PTExecutors.newSingleThreadScheduledExecutor(new NamedThreadFactory("OldestTargetedSweepTrackedTimestamp", true))), closeables);
    }
    TransactionManagersInitializer initializer = TransactionManagersInitializer.createInitialTables(keyValueService, schemas(), config().initializeAsync(), allSafeForLogging());
    TransactionComponents components = createTransactionComponents(closeables, metricsManager, lockAndTimestampServices, keyValueService, runtime);
    TransactionService transactionService = components.transactionService();
    ConflictDetectionManager conflictManager = ConflictDetectionManagers.create(keyValueService);
    SweepStrategyManager sweepStrategyManager = SweepStrategyManagers.createDefault(keyValueService);
    CleanupFollower follower = CleanupFollower.create(schemas());
    Cleaner cleaner = initializeCloseable(() -> new DefaultCleanerBuilder(keyValueService, lockAndTimestampServices.timelock(), ImmutableList.of(follower), transactionService, metricsManager).setBackgroundScrubAggressively(config().backgroundScrubAggressively()).setBackgroundScrubBatchSize(config().getBackgroundScrubBatchSize()).setBackgroundScrubFrequencyMillis(config().getBackgroundScrubFrequencyMillis()).setBackgroundScrubThreads(config().getBackgroundScrubThreads()).setPunchIntervalMillis(config().getPunchIntervalMillis()).setTransactionReadTimeout(config().getTransactionReadTimeoutMillis()).setInitializeAsync(config().initializeAsync()).buildCleaner(), closeables);
    MultiTableSweepQueueWriter targetedSweep = initializeCloseable(() -> uninitializedTargetedSweeper(metricsManager, config().targetedSweep(), follower, runtime.map(AtlasDbRuntimeConfig::targetedSweep)), closeables);
    Supplier<TransactionConfig> transactionConfigSupplier = runtime.map(AtlasDbRuntimeConfig::transaction).map(this::withConsolidatedGrabImmutableTsLockFlag);
    TimestampCache timestampCache = config().timestampCache().orElseGet(() -> new DefaultTimestampCache(metricsManager.getRegistry(), () -> runtime.get().getTimestampCacheSize()));
    ConflictTracer conflictTracer = lockDiagnosticComponents().map(LockDiagnosticComponents::clientLockDiagnosticCollector).<ConflictTracer>map(Function.identity()).orElse(ConflictTracer.NO_OP);
    Callback<TransactionManager> callbacks = new Callback.CallChain<>(timelockConsistencyCheckCallback(config(), runtime.get(), lockAndTimestampServices), targetedSweep.singleAttemptCallback(), asyncInitializationCallback(), createClearsTable());
    TransactionManager transactionManager = initializeCloseable(() -> SerializableTransactionManager.createInstrumented(metricsManager, keyValueService, lockAndTimestampServices.timelock(), lockAndTimestampServices.lockWatcher(), lockAndTimestampServices.managedTimestampService(), lockAndTimestampServices.lock(), transactionService, () -> AtlasDbConstraintCheckingMode.FULL_CONSTRAINT_CHECKING_THROWS_EXCEPTIONS, conflictManager, sweepStrategyManager, cleaner, () -> areTransactionManagerInitializationPrerequisitesSatisfied(initializer, lockAndTimestampServices), allowHiddenTableAccess(), derivedSnapshotConfig.concurrentGetRangesThreadPoolSize(), derivedSnapshotConfig.defaultGetRangesConcurrency(), config().initializeAsync(), timestampCache, targetedSweep, callbacks, validateLocksOnReads(), transactionConfigSupplier, conflictTracer, metricsFilterEvaluationContext(), installConfig.sharedResourcesConfig().map(SharedResourcesConfig::sharedGetRangesPoolSize)), closeables);
    transactionManager.registerClosingCallback(runtimeConfigRefreshable::close);
    timeLockFeedbackBackgroundTask.ifPresent(task -> transactionManager.registerClosingCallback(task::close));
    lockAndTimestampServices.resources().forEach(transactionManager::registerClosingCallback);
    transactionManager.registerClosingCallback(transactionService::close);
    components.schemaInstaller().ifPresent(installer -> transactionManager.registerClosingCallback(installer::close));
    transactionManager.registerClosingCallback(targetedSweep::close);
    initializeCloseable(() -> initializeSweepEndpointAndBackgroundProcess(metricsManager, config(), runtime, registrar(), keyValueService, transactionService, follower, transactionManager, runBackgroundSweepProcess()), closeables);
    initializeCloseable(initializeCompactBackgroundProcess(metricsManager, lockAndTimestampServices, keyValueService, transactionManager, runtime.map(AtlasDbRuntimeConfig::compact)), closeables);
    log.info("Successfully created, and now returning a transaction manager: this may not be fully initialised.");
    return transactionManager;
}
Also used : KeyValueServiceConfig(com.palantir.atlasdb.spi.KeyValueServiceConfig) SafeTableClearerKeyValueService(com.palantir.atlasdb.sweep.queue.clear.SafeTableClearerKeyValueService) SweepStatsKeyValueService(com.palantir.atlasdb.keyvalue.impl.SweepStatsKeyValueService) ValidatingQueryRewritingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ValidatingQueryRewritingKeyValueService) ProfilingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ProfilingKeyValueService) TracingKeyValueService(com.palantir.atlasdb.keyvalue.impl.TracingKeyValueService) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) TimelockTimestampServiceAdapter(com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter) SweepConfig(com.palantir.atlasdb.config.SweepConfig) ConflictTracer(com.palantir.atlasdb.debug.ConflictTracer) DefaultCleanerBuilder(com.palantir.atlasdb.cleaner.DefaultCleanerBuilder) TimestampCache(com.palantir.atlasdb.cache.TimestampCache) DefaultTimestampCache(com.palantir.atlasdb.cache.DefaultTimestampCache) SharedResourcesConfig(com.palantir.atlasdb.spi.SharedResourcesConfig) CleanupFollower(com.palantir.atlasdb.cleaner.CleanupFollower) Cleaner(com.palantir.atlasdb.cleaner.api.Cleaner) SweepStrategyManager(com.palantir.atlasdb.transaction.impl.SweepStrategyManager) TransactionService(com.palantir.atlasdb.transaction.service.TransactionService) TimeLockFeedbackBackgroundTask(com.palantir.lock.client.metrics.TimeLockFeedbackBackgroundTask) NamedThreadFactory(com.palantir.common.concurrent.NamedThreadFactory) MultiTableSweepQueueWriter(com.palantir.atlasdb.sweep.queue.MultiTableSweepQueueWriter) LockDiagnosticComponents(com.palantir.atlasdb.debug.LockDiagnosticComponents) FreshTimestampSupplierAdapter(com.palantir.atlasdb.factory.timestamp.FreshTimestampSupplierAdapter) TransactionConfig(com.palantir.atlasdb.transaction.TransactionConfig) ImmutableTransactionConfig(com.palantir.atlasdb.transaction.ImmutableTransactionConfig) DerivedSnapshotConfig(com.palantir.atlasdb.spi.DerivedSnapshotConfig) MetricsManager(com.palantir.atlasdb.util.MetricsManager) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) SafeTableClearerKeyValueService(com.palantir.atlasdb.sweep.queue.clear.SafeTableClearerKeyValueService) DefaultTimestampCache(com.palantir.atlasdb.cache.DefaultTimestampCache) ConflictDetectionManager(com.palantir.atlasdb.transaction.impl.ConflictDetectionManager) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig)

Aggregations

DefaultTimestampCache (com.palantir.atlasdb.cache.DefaultTimestampCache)2 TimestampCache (com.palantir.atlasdb.cache.TimestampCache)2 OffHeapTimestampCache (com.palantir.atlasdb.cache.OffHeapTimestampCache)1 CleanupFollower (com.palantir.atlasdb.cleaner.CleanupFollower)1 DefaultCleanerBuilder (com.palantir.atlasdb.cleaner.DefaultCleanerBuilder)1 Cleaner (com.palantir.atlasdb.cleaner.api.Cleaner)1 AtlasDbRuntimeConfig (com.palantir.atlasdb.config.AtlasDbRuntimeConfig)1 SweepConfig (com.palantir.atlasdb.config.SweepConfig)1 ConflictTracer (com.palantir.atlasdb.debug.ConflictTracer)1 LockDiagnosticComponents (com.palantir.atlasdb.debug.LockDiagnosticComponents)1 FreshTimestampSupplierAdapter (com.palantir.atlasdb.factory.timestamp.FreshTimestampSupplierAdapter)1 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)1 ProfilingKeyValueService (com.palantir.atlasdb.keyvalue.impl.ProfilingKeyValueService)1 SweepStatsKeyValueService (com.palantir.atlasdb.keyvalue.impl.SweepStatsKeyValueService)1 TracingKeyValueService (com.palantir.atlasdb.keyvalue.impl.TracingKeyValueService)1 ValidatingQueryRewritingKeyValueService (com.palantir.atlasdb.keyvalue.impl.ValidatingQueryRewritingKeyValueService)1 DerivedSnapshotConfig (com.palantir.atlasdb.spi.DerivedSnapshotConfig)1 KeyValueServiceConfig (com.palantir.atlasdb.spi.KeyValueServiceConfig)1 SharedResourcesConfig (com.palantir.atlasdb.spi.SharedResourcesConfig)1 MultiTableSweepQueueWriter (com.palantir.atlasdb.sweep.queue.MultiTableSweepQueueWriter)1