use of com.palantir.atlasdb.sweep.metrics.LegacySweepMetrics 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;
}
use of com.palantir.atlasdb.sweep.metrics.LegacySweepMetrics in project atlasdb by palantir.
the class AbstractBackgroundSweeperIntegrationTest method setup.
@Before
public void setup() {
kvs = SweepStatsKeyValueService.create(getKeyValueService(), services.getTimestampService(), () -> AtlasDbConstants.DEFAULT_SWEEP_WRITE_THRESHOLD, () -> AtlasDbConstants.DEFAULT_SWEEP_WRITE_SIZE_THRESHOLD, () -> true);
SweepStrategyManager ssm = SweepStrategyManagers.createDefault(kvs);
txService = TransactionServices.createV1TransactionService(kvs);
txManager = SweepTestUtils.setupTxManager(kvs, services.getLegacyTimelockService(), services.getTimestampManagementService(), ssm, txService);
CellsSweeper cellsSweeper = new CellsSweeper(txManager, kvs, ImmutableList.of());
SweepTaskRunner sweepRunner = new SweepTaskRunner(kvs, AbstractBackgroundSweeperIntegrationTest::getTimestamp, AbstractBackgroundSweeperIntegrationTest::getTimestamp, txService, cellsSweeper, null);
LegacySweepMetrics sweepMetrics = new LegacySweepMetrics(metricsManager.getRegistry());
specificTableSweeper = SpecificTableSweeper.create(txManager, kvs, sweepRunner, SweepTableFactory.of(), new NoOpBackgroundSweeperPerformanceLogger(), sweepMetrics, false);
sweepBatchConfigSource = AdjustableSweepBatchConfigSource.create(metricsManager, () -> sweepBatchConfig);
backgroundSweeper = new BackgroundSweepThread(txManager.getLockService(), NextTableToSweepProvider.create(kvs, txManager.getLockService(), specificTableSweeper.getSweepPriorityStore()), sweepBatchConfigSource, // sweepEnabled
() -> true, // sweepPauseMillis
() -> 10L, SweepPriorityOverrideConfig::defaultConfig, specificTableSweeper, SweepOutcomeMetrics.registerLegacy(metricsManager), new CountDownLatch(1), 0);
}
Aggregations