use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.
the class TargetedSweepMetricsTest method metricsAreNotRegisteredIfSweepStrategyNotTracked.
@Test
public void metricsAreNotRegisteredIfSweepStrategyNotTracked() {
MetricsManager anotherManager = MetricsManagers.createForTests();
TargetedSweepMetrics.createWithClock(anotherManager, kvs, () -> clockTime, TargetedSweepMetrics.MetricsConfiguration.builder().addTrackedSweeperStrategies(SweepStrategy.SweeperStrategy.THOROUGH).millisBetweenRecomputingMetrics(RECOMPUTE_MILLIS).build(), 8);
assertThat(anotherManager).hasNotRegisteredEnqueuedWritesConservativeMetric();
assertThat(anotherManager).hasEnqueuedWritesThoroughEqualTo(0);
}
use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.
the class TargetedSweepMetricsTest method untrackedSweepStrategyMetricsUpdatesAreSafelyIgnored.
@Test
public void untrackedSweepStrategyMetricsUpdatesAreSafelyIgnored() {
MetricsManager anotherManager = MetricsManagers.createForTests();
TargetedSweepMetrics anotherMetrics = TargetedSweepMetrics.createWithClock(anotherManager, kvs, () -> clockTime, TargetedSweepMetrics.MetricsConfiguration.builder().addTrackedSweeperStrategies(SweepStrategy.SweeperStrategy.THOROUGH).millisBetweenRecomputingMetrics(RECOMPUTE_MILLIS).build(), 8);
anotherMetrics.updateEnqueuedWrites(CONS_ZERO, 5);
assertThat(anotherManager).hasNotRegisteredEnqueuedWritesConservativeMetric();
anotherMetrics.registerOccurrenceOf(CONS_ZERO, SweepOutcome.SUCCESS);
assertThat(anotherManager).hasNotRegisteredTargetedOutcome(SweepStrategy.SweeperStrategy.CONSERVATIVE, SweepOutcome.SUCCESS);
anotherMetrics.updateEnqueuedWrites(THOR_ZERO, 5);
assertThat(anotherManager).hasEnqueuedWritesThoroughEqualTo(5);
anotherMetrics.registerOccurrenceOf(THOR_ZERO, SweepOutcome.SUCCESS);
assertThat(anotherManager).hasTargetedOutcomeEqualTo(SweepStrategy.SweeperStrategy.THOROUGH, SweepOutcome.SUCCESS, 1L);
}
use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.
the class ToplistDeltaFilteringTableLevelMetricsControllerTest method operatesCorrectlyWithSharedContexts.
@Test
public void operatesCorrectlyWithSharedContexts() {
MetricsManager otherManager = MetricsManagers.createAlwaysSafeAndFilteringForTests();
ToplistDeltaFilteringTableLevelMetricsController otherController = new ToplistDeltaFilteringTableLevelMetricsController(context, otherManager, mockClock);
Map<Integer, Counter> counters = KeyedStream.of(ImmutableList.of(1, 2, 4)).map(value -> controller.createAndRegisterCounter(Class.class, "metricName", TableReference.create(Namespace.create("namespace"), "table" + value))).collectToMap();
counters.forEach((value, counter) -> counter.inc(value));
Counter otherControllersCounter = otherController.createAndRegisterCounter(Class.class, "metricName", TableReference.create(Namespace.create("namespace"), "table3"));
otherControllersCounter.inc(3);
assertThat(metricsManager.getPublishableMetrics().getMetrics()).containsOnlyKeys(getMetricName("table2"), getMetricName("table4"));
assertThat(otherManager.getPublishableMetrics().getMetrics()).containsOnlyKeys(getMetricName("table3"));
}
use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.
the class PaxosResourcesFactory method configureLeaderForAllClients.
private static PaxosResources configureLeaderForAllClients(ImmutablePaxosResources.Builder resourcesBuilder, TimelockPaxosInstallationContext install, MetricsManager metrics, Supplier<PaxosRuntimeConfiguration> paxosRuntime, PaxosRemoteClients remoteClients) {
TimelockPaxosMetrics timelockMetrics = TimelockPaxosMetrics.of(PaxosUseCase.LEADER_FOR_ALL_CLIENTS, metrics);
Factories.LeaderPingHealthCheckFactory healthCheckPingersFactory = dependencies -> {
PingableLeader local = dependencies.components().pingableLeader(PaxosUseCase.PSEUDO_LEADERSHIP_CLIENT);
List<PingableLeader> remotes = dependencies.remoteClients().nonBatchPingableLeaders();
return LocalAndRemotes.of(new SingleLeaderHealthCheckPinger(local), remotes.stream().map(SingleLeaderHealthCheckPinger::new).collect(Collectors.toList()));
};
Factories.PaxosLatestRoundVerifierFactory latestRoundVerifierFactory = acceptorClient -> new CoalescingPaxosLatestRoundVerifier(new PaxosLatestRoundVerifierImpl(acceptorClient));
LeadershipContextFactory factory = ImmutableLeadershipContextFactory.builder().install(install).remoteClients(remoteClients).runtime(paxosRuntime).useCase(PaxosUseCase.LEADER_FOR_ALL_CLIENTS).metrics(timelockMetrics).networkClientFactoryBuilder(ImmutableSingleLeaderNetworkClientFactories.builder().useBatchedEndpoints(() -> paxosRuntime.get().enableBatchingForSingleLeader())).leaderPingerFactoryBuilder(ImmutableSingleLeaderPingerFactory.builder()).healthCheckPingersFactory(healthCheckPingersFactory).latestRoundVerifierFactory(latestRoundVerifierFactory).build();
return resourcesBuilder.leadershipContextFactory(factory).putLeadershipBatchComponents(PaxosUseCase.LEADER_FOR_ALL_CLIENTS, factory.components()).addAdhocResources(new BatchPingableLeaderResource(install.nodeUuid(), factory.components())).addAdhocResources(new LeaderAcceptorResource(factory.components().acceptor(PaxosUseCase.PSEUDO_LEADERSHIP_CLIENT)), new LeaderLearnerResource(factory.components().learner(PaxosUseCase.PSEUDO_LEADERSHIP_CLIENT)), factory.components().pingableLeader(PaxosUseCase.PSEUDO_LEADERSHIP_CLIENT)).timeLockCorruptionComponents(timeLockCorruptionComponents(install.sqliteDataSource(), remoteClients)).build();
}
Aggregations