Search in sources :

Example 1 with SweepConfig

use of com.palantir.atlasdb.config.SweepConfig in project atlasdb by palantir.

the class TransactionManagers method serializableInternal.

private SerializableTransactionManager serializableInternal(@Output List<AutoCloseable> closeables) {
    AtlasDbMetrics.setMetricRegistries(globalMetricsRegistry(), globalTaggedMetricRegistry());
    final AtlasDbConfig config = config();
    checkInstallConfig(config);
    AtlasDbRuntimeConfig defaultRuntime = AtlasDbRuntimeConfig.defaultRuntimeConfig();
    Supplier<AtlasDbRuntimeConfig> runtimeConfigSupplier = () -> runtimeConfigSupplier().get().orElse(defaultRuntime);
    QosClient qosClient = initializeCloseable(() -> getQosClient(JavaSuppliers.compose(AtlasDbRuntimeConfig::qos, runtimeConfigSupplier)), closeables);
    ServiceDiscoveringAtlasSupplier atlasFactory = new ServiceDiscoveringAtlasSupplier(config.keyValueService(), JavaSuppliers.compose(AtlasDbRuntimeConfig::keyValueService, runtimeConfigSupplier), config.leader(), config.namespace(), config.initializeAsync(), qosClient);
    LockRequest.setDefaultLockTimeout(SimpleTimeDuration.of(config.getDefaultLockTimeoutSeconds(), TimeUnit.SECONDS));
    LockAndTimestampServices lockAndTimestampServices = createLockAndTimestampServices(config, runtimeConfigSupplier, registrar(), () -> LockServiceImpl.create(lockServerOptions()), atlasFactory::getTimestampService, atlasFactory.getTimestampStoreInvalidator(), userAgent());
    KvsProfilingLogger.setSlowLogThresholdMillis(config.getKvsSlowLogThresholdMillis());
    Supplier<SweepConfig> sweepConfig = JavaSuppliers.compose(AtlasDbRuntimeConfig::sweep, runtimeConfigSupplier);
    KeyValueService keyValueService = initializeCloseable(() -> {
        KeyValueService kvs = atlasFactory.getKeyValueService();
        kvs = ProfilingKeyValueService.create(kvs);
        kvs = SweepStatsKeyValueService.create(kvs, new TimelockTimestampServiceAdapter(lockAndTimestampServices.timelock()), JavaSuppliers.compose(SweepConfig::writeThreshold, sweepConfig), JavaSuppliers.compose(SweepConfig::writeSizeThreshold, sweepConfig));
        kvs = TracingKeyValueService.create(kvs);
        kvs = AtlasDbMetrics.instrument(KeyValueService.class, kvs, MetricRegistry.name(KeyValueService.class));
        return ValidatingQueryRewritingKeyValueService.create(kvs);
    }, closeables);
    SchemaMetadataService schemaMetadataService = SchemaMetadataServiceImpl.create(keyValueService, config.initializeAsync());
    TransactionManagersInitializer initializer = TransactionManagersInitializer.createInitialTables(keyValueService, schemas(), schemaMetadataService, config.initializeAsync());
    PersistentLockService persistentLockService = createAndRegisterPersistentLockService(keyValueService, registrar(), config.initializeAsync());
    TransactionService transactionService = AtlasDbMetrics.instrument(TransactionService.class, TransactionServices.createTransactionService(keyValueService));
    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).setBackgroundScrubAggressively(config.backgroundScrubAggressively()).setBackgroundScrubBatchSize(config.getBackgroundScrubBatchSize()).setBackgroundScrubFrequencyMillis(config.getBackgroundScrubFrequencyMillis()).setBackgroundScrubThreads(config.getBackgroundScrubThreads()).setPunchIntervalMillis(config.getPunchIntervalMillis()).setTransactionReadTimeout(config.getTransactionReadTimeoutMillis()).setInitializeAsync(config.initializeAsync()).buildCleaner(), closeables);
    SerializableTransactionManager transactionManager = initializeCloseable(() -> SerializableTransactionManager.create(keyValueService, lockAndTimestampServices.timelock(), lockAndTimestampServices.lock(), transactionService, Suppliers.ofInstance(AtlasDbConstraintCheckingMode.FULL_CONSTRAINT_CHECKING_THROWS_EXCEPTIONS), conflictManager, sweepStrategyManager, cleaner, () -> areTransactionManagerInitializationPrerequisitesSatisfied(initializer, lockAndTimestampServices), allowHiddenTableAccess(), () -> runtimeConfigSupplier.get().transaction().getLockAcquireTimeoutMillis(), config.keyValueService().concurrentGetRangesThreadPoolSize(), config.keyValueService().defaultGetRangesConcurrency(), config.initializeAsync(), () -> runtimeConfigSupplier.get().getTimestampCacheSize(), MultiTableSweepQueueWriter.NO_OP, wrapInitializationCallbackAndAddConsistencyChecks(config, runtimeConfigSupplier.get(), lockAndTimestampServices, asyncInitializationCallback())), closeables);
    PersistentLockManager persistentLockManager = initializeCloseable(() -> new PersistentLockManager(persistentLockService, config.getSweepPersistentLockWaitMillis()), closeables);
    initializeCloseable(() -> initializeSweepEndpointAndBackgroundProcess(config, runtimeConfigSupplier, registrar(), keyValueService, transactionService, sweepStrategyManager, follower, transactionManager, persistentLockManager), closeables);
    initializeCloseable(initializeCompactBackgroundProcess(lockAndTimestampServices, keyValueService, transactionManager, JavaSuppliers.compose(AtlasDbRuntimeConfig::compact, runtimeConfigSupplier)), closeables);
    return transactionManager;
}
Also used : SweepStrategyManager(com.palantir.atlasdb.transaction.impl.SweepStrategyManager) 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) TransactionService(com.palantir.atlasdb.transaction.service.TransactionService) PersistentLockManager(com.palantir.atlasdb.sweep.PersistentLockManager) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) QosClient(com.palantir.atlasdb.qos.QosClient) AtlasDbQosClient(com.palantir.atlasdb.qos.client.AtlasDbQosClient) SweepConfig(com.palantir.atlasdb.config.SweepConfig) SchemaMetadataService(com.palantir.atlasdb.schema.metadata.SchemaMetadataService) NoOpPersistentLockService(com.palantir.atlasdb.persistentlock.NoOpPersistentLockService) KvsBackedPersistentLockService(com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService) PersistentLockService(com.palantir.atlasdb.persistentlock.PersistentLockService) DefaultCleanerBuilder(com.palantir.atlasdb.cleaner.DefaultCleanerBuilder) ConflictDetectionManager(com.palantir.atlasdb.transaction.impl.ConflictDetectionManager) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) CleanupFollower(com.palantir.atlasdb.cleaner.CleanupFollower) Cleaner(com.palantir.atlasdb.cleaner.Cleaner)

Example 2 with SweepConfig

use of com.palantir.atlasdb.config.SweepConfig in project atlasdb by palantir.

the class KeyValueServiceModule method provideWrappedKeyValueService.

@Provides
@Singleton
@Named("kvs")
public KeyValueService provideWrappedKeyValueService(@Named("rawKvs") KeyValueService rawKvs, TimestampService tss, ServicesConfig config) {
    KvsProfilingLogger.setSlowLogThresholdMillis(config.atlasDbConfig().getKvsSlowLogThresholdMillis());
    KeyValueService kvs = ProfilingKeyValueService.create(rawKvs);
    kvs = TracingKeyValueService.create(kvs);
    kvs = AtlasDbMetrics.instrument(KeyValueService.class, kvs);
    kvs = ValidatingQueryRewritingKeyValueService.create(kvs);
    SweepConfig sweepConfig = config.atlasDbRuntimeConfig().sweep();
    kvs = SweepStatsKeyValueService.create(kvs, tss, sweepConfig::writeThreshold, sweepConfig::writeSizeThreshold);
    TransactionTables.createTables(kvs);
    ImmutableSet<Schema> schemas = ImmutableSet.<Schema>builder().add(SweepSchema.INSTANCE.getLatestSchema()).add(CompactSchema.INSTANCE.getLatestSchema()).addAll(config.schemas()).build();
    for (Schema schema : schemas) {
        Schemas.createTablesAndIndexes(schema, kvs);
    }
    return kvs;
}
Also used : SweepConfig(com.palantir.atlasdb.config.SweepConfig) ValidatingQueryRewritingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ValidatingQueryRewritingKeyValueService) TracingKeyValueService(com.palantir.atlasdb.keyvalue.impl.TracingKeyValueService) ProfilingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ProfilingKeyValueService) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) SweepStatsKeyValueService(com.palantir.atlasdb.keyvalue.impl.SweepStatsKeyValueService) SweepSchema(com.palantir.atlasdb.schema.SweepSchema) CompactSchema(com.palantir.atlasdb.schema.CompactSchema) Schema(com.palantir.atlasdb.table.description.Schema) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Aggregations

SweepConfig (com.palantir.atlasdb.config.SweepConfig)2 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)2 ProfilingKeyValueService (com.palantir.atlasdb.keyvalue.impl.ProfilingKeyValueService)2 SweepStatsKeyValueService (com.palantir.atlasdb.keyvalue.impl.SweepStatsKeyValueService)2 TracingKeyValueService (com.palantir.atlasdb.keyvalue.impl.TracingKeyValueService)2 ValidatingQueryRewritingKeyValueService (com.palantir.atlasdb.keyvalue.impl.ValidatingQueryRewritingKeyValueService)2 Cleaner (com.palantir.atlasdb.cleaner.Cleaner)1 CleanupFollower (com.palantir.atlasdb.cleaner.CleanupFollower)1 DefaultCleanerBuilder (com.palantir.atlasdb.cleaner.DefaultCleanerBuilder)1 AtlasDbConfig (com.palantir.atlasdb.config.AtlasDbConfig)1 AtlasDbRuntimeConfig (com.palantir.atlasdb.config.AtlasDbRuntimeConfig)1 ImmutableAtlasDbConfig (com.palantir.atlasdb.config.ImmutableAtlasDbConfig)1 InMemoryAtlasDbConfig (com.palantir.atlasdb.memory.InMemoryAtlasDbConfig)1 KvsBackedPersistentLockService (com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService)1 NoOpPersistentLockService (com.palantir.atlasdb.persistentlock.NoOpPersistentLockService)1 PersistentLockService (com.palantir.atlasdb.persistentlock.PersistentLockService)1 QosClient (com.palantir.atlasdb.qos.QosClient)1 AtlasDbQosClient (com.palantir.atlasdb.qos.client.AtlasDbQosClient)1 CompactSchema (com.palantir.atlasdb.schema.CompactSchema)1 SweepSchema (com.palantir.atlasdb.schema.SweepSchema)1