use of com.palantir.atlasdb.config.AtlasDbConfig 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;
}
use of com.palantir.atlasdb.config.AtlasDbConfig in project atlasdb by palantir.
the class TransactionManagersTest method setsGlobalDefaultLockTimeout.
@Test
public void setsGlobalDefaultLockTimeout() {
TimeDuration expectedTimeout = SimpleTimeDuration.of(47, TimeUnit.SECONDS);
AtlasDbConfig atlasDbConfig = ImmutableAtlasDbConfig.builder().keyValueService(new InMemoryAtlasDbConfig()).defaultLockTimeoutSeconds((int) expectedTimeout.getTime()).build();
TransactionManagers.builder().config(atlasDbConfig).userAgent("test").globalMetricsRegistry(new MetricRegistry()).globalTaggedMetricRegistry(DefaultTaggedMetricRegistry.getDefault()).registrar(environment).build().serializable();
assertEquals(expectedTimeout, LockRequest.getDefaultLockTimeout());
LockRequest lockRequest = LockRequest.builder(ImmutableSortedMap.of(StringLockDescriptor.of("foo"), LockMode.WRITE)).build();
assertEquals(expectedTimeout, lockRequest.getLockTimeout());
}
use of com.palantir.atlasdb.config.AtlasDbConfig in project atlasdb by palantir.
the class TransactionManagersTest method runsClosingCallbackOnShutdown.
@Test
public void runsClosingCallbackOnShutdown() throws Exception {
AtlasDbConfig atlasDbConfig = ImmutableAtlasDbConfig.builder().keyValueService(new InMemoryAtlasDbConfig()).defaultLockTimeoutSeconds(120).build();
Runnable callback = mock(Runnable.class);
SerializableTransactionManager manager = TransactionManagers.builder().config(atlasDbConfig).userAgent("test").globalMetricsRegistry(new MetricRegistry()).globalTaggedMetricRegistry(DefaultTaggedMetricRegistry.getDefault()).registrar(environment).build().serializable();
manager.registerClosingCallback(callback);
manager.close();
verify(callback, times(1)).run();
}
use of com.palantir.atlasdb.config.AtlasDbConfig in project atlasdb by palantir.
the class AtlasDbConsoleCommandTest method getConfigFromConsoleCommand.
private AtlasDbConfig getConfigFromConsoleCommand(Map<String, Object> params, AtlasDbConfig config) throws JsonProcessingException {
AtomicReference<AtlasDbConfig> cliConfig = new AtomicReference<>();
new AtlasDbConsoleCommand<AtlasDbDropwizardConfig>(AtlasDbDropwizardConfig.class) {
@Override
protected void runAtlasDbConsole(List<String> allArgs) {
try {
cliConfig.set(AtlasDbConfigs.loadFromString(allArgs.get(2), null, AtlasDbConfig.class));
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
}.run(mock(Bootstrap.class), new Namespace(params), new AtlasDbDropwizardConfig(config));
return cliConfig.get();
}
use of com.palantir.atlasdb.config.AtlasDbConfig in project atlasdb by palantir.
the class AtlasDbConsoleCommandTest method lockAndTimestampFieldsShouldBeEmptyWhenRunningOffline.
@Test
public void lockAndTimestampFieldsShouldBeEmptyWhenRunningOffline() throws JsonProcessingException {
AtlasDbConfig cliConfig = getConfigFromConsoleCommand(OFFLINE_PARAMS, MINIMAL_LEADER_CONFIG);
assertThat(cliConfig.lock().isPresent()).describedAs("Lock block must be absent").isFalse();
assertThat(cliConfig.timestamp().isPresent()).describedAs("Timestamp block must be absent").isFalse();
}
Aggregations