use of com.palantir.atlasdb.config.ShouldRunBackgroundSweepSupplier in project atlasdb by palantir.
the class TransactionManagers method initializeSweepEndpointAndBackgroundProcess.
private static BackgroundSweeperImpl initializeSweepEndpointAndBackgroundProcess(MetricsManager metricsManager, AtlasDbConfig config, Supplier<AtlasDbRuntimeConfig> runtimeConfigSupplier, Consumer<Object> env, KeyValueService kvs, TransactionService transactionService, CleanupFollower follower, TransactionManager transactionManager, boolean runInBackground) {
CellsSweeper cellsSweeper = new CellsSweeper(transactionManager, kvs, ImmutableList.of(follower));
LegacySweepMetrics sweepMetrics = new LegacySweepMetrics(metricsManager.getRegistry());
SweepTaskRunner sweepRunner = new SweepTaskRunner(kvs, transactionManager::getUnreadableTimestamp, transactionManager::getImmutableTimestamp, transactionService, cellsSweeper, sweepMetrics);
BackgroundSweeperPerformanceLogger sweepPerfLogger = new NoOpBackgroundSweeperPerformanceLogger();
AdjustableSweepBatchConfigSource sweepBatchConfigSource = AdjustableSweepBatchConfigSource.create(metricsManager, () -> getSweepBatchConfig(runtimeConfigSupplier.get().sweep()));
SpecificTableSweeper specificTableSweeper = initializeSweepEndpoint(env, kvs, transactionManager, sweepRunner, sweepPerfLogger, sweepMetrics, config.initializeAsync(), sweepBatchConfigSource);
boolean sweepQueueWritesEnabled = config.targetedSweep().enableSweepQueueWrites();
BackgroundSweeperImpl backgroundSweeper = BackgroundSweeperImpl.create(metricsManager, sweepBatchConfigSource, new ShouldRunBackgroundSweepSupplier(() -> runtimeConfigSupplier.get().sweep(), sweepQueueWritesEnabled)::getAsBoolean, () -> runtimeConfigSupplier.get().sweep().sweepThreads(), () -> runtimeConfigSupplier.get().sweep().pauseMillis(), () -> runtimeConfigSupplier.get().sweep().sweepPriorityOverrides(), specificTableSweeper);
transactionManager.registerClosingCallback(backgroundSweeper::shutdown);
if (runInBackground) {
backgroundSweeper.runInBackground();
}
return backgroundSweeper;
}
Aggregations