use of com.palantir.atlasdb.cleaner.Cleaner in project atlasdb by palantir.
the class SweepTestUtils method setupTxManager.
public static SerializableTransactionManager setupTxManager(KeyValueService kvs, TimestampService tsService, SweepStrategyManager ssm, TransactionService txService) {
LockClient lockClient = LockClient.of("sweep client");
LockService lockService = LockServiceImpl.create(LockServerOptions.builder().isStandaloneServer(false).build());
Supplier<AtlasDbConstraintCheckingMode> constraints = () -> AtlasDbConstraintCheckingMode.NO_CONSTRAINT_CHECKING;
ConflictDetectionManager cdm = ConflictDetectionManagers.createWithoutWarmingCache(kvs);
Cleaner cleaner = new NoOpCleaner();
SerializableTransactionManager txManager = SerializableTransactionManager.createForTest(kvs, tsService, lockClient, lockService, txService, constraints, cdm, ssm, cleaner, AbstractTransactionTest.GET_RANGES_THREAD_POOL_SIZE, AbstractTransactionTest.DEFAULT_GET_RANGES_CONCURRENCY, () -> AtlasDbConstants.DEFAULT_TIMESTAMP_CACHE_SIZE, InMemorySweepQueue.writer());
setupTables(kvs);
return txManager;
}
use of com.palantir.atlasdb.cleaner.Cleaner in project atlasdb by palantir.
the class TableTasksTest method setup.
@Before
public void setup() {
kvs = new InMemoryKeyValueService(true);
TimestampService tsService = new InMemoryTimestampService();
LockClient lockClient = LockClient.of("sweep client");
lockService = LockServiceImpl.create(LockServerOptions.builder().isStandaloneServer(false).build());
TransactionService txService = TransactionServices.createTransactionService(kvs);
Supplier<AtlasDbConstraintCheckingMode> constraints = Suppliers.ofInstance(AtlasDbConstraintCheckingMode.NO_CONSTRAINT_CHECKING);
ConflictDetectionManager cdm = ConflictDetectionManagers.createWithoutWarmingCache(kvs);
SweepStrategyManager ssm = SweepStrategyManagers.createDefault(kvs);
Cleaner cleaner = new NoOpCleaner();
SerializableTransactionManager transactionManager = SerializableTransactionManager.createForTest(kvs, tsService, lockClient, lockService, txService, constraints, cdm, ssm, cleaner, AbstractTransactionTest.GET_RANGES_THREAD_POOL_SIZE, AbstractTransactionTest.DEFAULT_GET_RANGES_CONCURRENCY, () -> AtlasDbConstants.DEFAULT_TIMESTAMP_CACHE_SIZE, MultiTableSweepQueueWriter.NO_OP);
txManager = transactionManager;
}
use of com.palantir.atlasdb.cleaner.Cleaner 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.cleaner.Cleaner in project atlasdb by palantir.
the class InMemoryAtlasDbFactory method createInMemoryTransactionManagerInternal.
private static SerializableTransactionManager createInMemoryTransactionManagerInternal(Set<Schema> schemas) {
TimestampService ts = new InMemoryTimestampService();
KeyValueService keyValueService = new InMemoryKeyValueService(false);
schemas.forEach(s -> Schemas.createTablesAndIndexes(s, keyValueService));
TransactionTables.createTables(keyValueService);
TransactionService transactionService = TransactionServices.createTransactionService(keyValueService);
LockService lock = LockRefreshingLockService.create(LockServiceImpl.create(LockServerOptions.builder().isStandaloneServer(false).build()));
LockClient client = LockClient.of("in memory atlasdb instance");
ConflictDetectionManager conflictManager = ConflictDetectionManagers.createWithoutWarmingCache(keyValueService);
SweepStrategyManager sweepStrategyManager = SweepStrategyManagers.createDefault(keyValueService);
CleanupFollower follower = CleanupFollower.create(schemas);
Cleaner cleaner = new DefaultCleanerBuilder(keyValueService, lock, ts, client, ImmutableList.of(follower), transactionService).buildCleaner();
SerializableTransactionManager ret = SerializableTransactionManager.createForTest(keyValueService, ts, client, lock, transactionService, Suppliers.ofInstance(AtlasDbConstraintCheckingMode.FULL_CONSTRAINT_CHECKING_THROWS_EXCEPTIONS), conflictManager, sweepStrategyManager, cleaner, DEFAULT_MAX_CONCURRENT_RANGES, DEFAULT_GET_RANGES_CONCURRENCY, () -> DEFAULT_TIMESTAMP_CACHE_SIZE, MultiTableSweepQueueWriter.NO_OP);
cleaner.start(ret);
return ret;
}
Aggregations