Search in sources :

Example 21 with MetricsManager

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);
}
Also used : MetricsManager(com.palantir.atlasdb.util.MetricsManager) Test(org.junit.Test)

Example 22 with MetricsManager

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);
}
Also used : MetricsManager(com.palantir.atlasdb.util.MetricsManager) Test(org.junit.Test)

Example 23 with MetricsManager

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"));
}
Also used : IntStream(java.util.stream.IntStream) Clock(com.codahale.metrics.Clock) Namespace(com.palantir.atlasdb.keyvalue.api.Namespace) MetricName(com.palantir.tritium.metrics.registry.MetricName) ImmutableMap(com.google.common.collect.ImmutableMap) KeyedStream(com.palantir.common.streams.KeyedStream) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) MetricsManagers(com.palantir.atlasdb.util.MetricsManagers) List(java.util.List) MetricsManager(com.palantir.atlasdb.util.MetricsManager) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) Counter(com.codahale.metrics.Counter) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Mockito.mock(org.mockito.Mockito.mock) Before(org.junit.Before) Counter(com.codahale.metrics.Counter) MetricsManager(com.palantir.atlasdb.util.MetricsManager) Test(org.junit.Test)

Example 24 with MetricsManager

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();
}
Also used : PersistentTimestampServiceImpl(com.palantir.timestamp.PersistentTimestampServiceImpl) PaxosLeaderMode(com.palantir.timelock.config.PaxosInstallConfiguration.PaxosLeaderMode) TimeLockInstallConfiguration(com.palantir.timelock.config.TimeLockInstallConfiguration) PaxosLearnerNetworkClient(com.palantir.paxos.PaxosLearnerNetworkClient) Supplier(java.util.function.Supplier) TrustContext(com.palantir.conjure.java.config.ssl.TrustContext) TimestampBoundStore(com.palantir.timestamp.TimestampBoundStore) LocalHistoryLoader(com.palantir.timelock.history.LocalHistoryLoader) MetricsManager(com.palantir.atlasdb.util.MetricsManager) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) SqlitePaxosStateLogHistory(com.palantir.timelock.history.sqlite.SqlitePaxosStateLogHistory) Value(org.immutables.value.Value) ClusterConfiguration(com.palantir.timelock.config.ClusterConfiguration) DataSource(javax.sql.DataSource) Suppliers(com.google.common.base.Suppliers) RemoteCorruptionDetector(com.palantir.timelock.corruption.detection.RemoteCorruptionDetector) PredicateSwitchedProxy(com.palantir.common.proxy.PredicateSwitchedProxy) SqliteConnections(com.palantir.paxos.SqliteConnections) Path(java.nio.file.Path) PaxosProposerImpl(com.palantir.paxos.PaxosProposerImpl) PaxosLogHistoryProvider(com.palantir.timelock.history.PaxosLogHistoryProvider) OrderableSlsVersion(com.palantir.sls.versions.OrderableSlsVersion) CoalescingPaxosLatestRoundVerifier(com.palantir.paxos.CoalescingPaxosLatestRoundVerifier) PaxosLatestRoundVerifierImpl(com.palantir.paxos.PaxosLatestRoundVerifierImpl) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) PaxosRemotingUtils(com.palantir.timelock.paxos.PaxosRemotingUtils) SslSocketFactories(com.palantir.conjure.java.config.ssl.SslSocketFactories) TimeLockDialogueServiceProvider(com.palantir.timelock.paxos.TimeLockDialogueServiceProvider) PaxosRuntimeConfiguration(com.palantir.timelock.config.PaxosRuntimeConfiguration) LocalTimestampInvariantsVerifier(com.palantir.timelock.corruption.detection.LocalTimestampInvariantsVerifier) PaxosProposer(com.palantir.paxos.PaxosProposer) List(java.util.List) PaxosAcceptorNetworkClient(com.palantir.paxos.PaxosAcceptorNetworkClient) CorruptionHealthCheck(com.palantir.timelock.corruption.detection.CorruptionHealthCheck) LocalCorruptionDetector(com.palantir.timelock.corruption.detection.LocalCorruptionDetector) ManagedTimestampService(com.palantir.timestamp.ManagedTimestampService) HikariDataSource(com.zaxxer.hikari.HikariDataSource) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) PingableLeader(com.palantir.leader.PingableLeader) CoalescingPaxosLatestRoundVerifier(com.palantir.paxos.CoalescingPaxosLatestRoundVerifier) PaxosLatestRoundVerifierImpl(com.palantir.paxos.PaxosLatestRoundVerifierImpl) PingableLeader(com.palantir.leader.PingableLeader) List(java.util.List) SslSocketFactories(com.palantir.conjure.java.config.ssl.SslSocketFactories)

Aggregations

MetricsManager (com.palantir.atlasdb.util.MetricsManager)24 Optional (java.util.Optional)9 UserAgent (com.palantir.conjure.java.api.config.service.UserAgent)8 List (java.util.List)7 Refreshable (com.palantir.refreshable.Refreshable)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)5 MetricsManagers (com.palantir.atlasdb.util.MetricsManagers)5 ManagedTimestampService (com.palantir.timestamp.ManagedTimestampService)5 Set (java.util.Set)5 Test (org.junit.Test)5 AuxiliaryRemotingParameters (com.palantir.atlasdb.config.AuxiliaryRemotingParameters)4 ServerListConfig (com.palantir.atlasdb.config.ServerListConfig)4 MultiTableSweepQueueWriter (com.palantir.atlasdb.sweep.queue.MultiTableSweepQueueWriter)4 TransactionManager (com.palantir.atlasdb.transaction.api.TransactionManager)4 ConflictDetectionManager (com.palantir.atlasdb.transaction.impl.ConflictDetectionManager)4 SafeLogger (com.palantir.logsafe.logger.SafeLogger)4 SafeLoggerFactory (com.palantir.logsafe.logger.SafeLoggerFactory)4 Map (java.util.Map)4 Collectors (java.util.stream.Collectors)4