Search in sources :

Example 1 with MetricsManager

use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.

the class CassandraServiceTest method clientPoolWithParams.

private CassandraService clientPoolWithParams(ImmutableSet<InetSocketAddress> servers, ImmutableSet<InetSocketAddress> serversInPool, double weighting) {
    config = ImmutableCassandraKeyValueServiceConfig.builder().replicationFactor(3).credentials(ImmutableCassandraCredentialsConfig.builder().username("username").password("password").build()).servers(ImmutableDefaultConfig.builder().addAllThriftHosts(servers).build()).localHostWeighting(weighting).consecutiveAbsencesBeforePoolRemoval(1).build();
    blacklist = new Blacklist(config);
    MetricsManager metricsManager = MetricsManagers.createForTests();
    CassandraService service = new CassandraService(metricsManager, config, blacklist, new CassandraClientPoolMetrics(metricsManager));
    service.cacheInitialCassandraHosts();
    serversInPool.forEach(service::addPool);
    return service;
}
Also used : MetricsManager(com.palantir.atlasdb.util.MetricsManager) Blacklist(com.palantir.atlasdb.keyvalue.cassandra.Blacklist)

Example 2 with MetricsManager

use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.

the class TransactionManagers method setUpMetricsAndGetMetricsManager.

private MetricsManager setUpMetricsAndGetMetricsManager() {
    MetricRegistry internalAtlasDbMetrics = new MetricRegistry();
    TaggedMetricRegistry internalTaggedAtlasDbMetrics = new DefaultTaggedMetricRegistry();
    MetricsManager metricsManager = MetricsManagers.of(internalAtlasDbMetrics, internalTaggedAtlasDbMetrics, runtimeConfig().map(runtimeConfigRefreshable -> runtimeConfigRefreshable.map(maybeRuntime -> maybeRuntime.map(AtlasDbRuntimeConfig::enableMetricFiltering).orElse(true))).orElseGet(() -> Refreshable.only(true)));
    globalTaggedMetricRegistry().addMetrics(AtlasDbMetricNames.LIBRARY_ORIGIN_TAG, AtlasDbMetricNames.LIBRARY_ORIGIN_VALUE, metricsManager.getPublishableMetrics());
    return metricsManager;
}
Also used : TransactionService(com.palantir.atlasdb.transaction.service.TransactionService) NoOpBackgroundSweeperPerformanceLogger(com.palantir.atlasdb.sweep.NoOpBackgroundSweeperPerformanceLogger) SafeTableClearerKeyValueService(com.palantir.atlasdb.sweep.queue.clear.SafeTableClearerKeyValueService) SharedResourcesConfig(com.palantir.atlasdb.spi.SharedResourcesConfig) TimelockTimestampServiceAdapter(com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter) KeyValueServicePuncherStore(com.palantir.atlasdb.cleaner.KeyValueServicePuncherStore) TargetedSweepTableFactory(com.palantir.atlasdb.schema.generated.TargetedSweepTableFactory) LockServerOptions(com.palantir.lock.LockServerOptions) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) GlobalClock(com.palantir.atlasdb.cleaner.GlobalClock) TimeLockRequestBatcherProviders(com.palantir.atlasdb.config.TimeLockRequestBatcherProviders) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) CoordinationServices(com.palantir.atlasdb.internalschema.persistence.CoordinationServices) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) AtlasDbConstants(com.palantir.atlasdb.AtlasDbConstants) Refreshable(com.palantir.refreshable.Refreshable) SweeperServiceImpl(com.palantir.atlasdb.sweep.SweeperServiceImpl) ConflictDetectionManagers(com.palantir.atlasdb.transaction.impl.ConflictDetectionManagers) NamedThreadFactory(com.palantir.common.concurrent.NamedThreadFactory) TargetedSweepRuntimeConfig(com.palantir.atlasdb.sweep.queue.config.TargetedSweepRuntimeConfig) TargetedSweepSchema(com.palantir.atlasdb.schema.TargetedSweepSchema) TimeLockFeedbackBackgroundTask(com.palantir.lock.client.metrics.TimeLockFeedbackBackgroundTask) Set(java.util.Set) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) MetricsManagers(com.palantir.atlasdb.util.MetricsManagers) SweepBatchConfig(com.palantir.atlasdb.sweep.SweepBatchConfig) ServicesConfigBlock(com.palantir.conjure.java.api.config.service.ServicesConfigBlock) KvsProfilingLogger(com.palantir.atlasdb.logging.KvsProfilingLogger) Stream(java.util.stream.Stream) MetricsFilterEvaluationContext(com.palantir.atlasdb.transaction.impl.metrics.MetricsFilterEvaluationContext) KeyValueServiceConfig(com.palantir.atlasdb.spi.KeyValueServiceConfig) ImmutableTimestampCorroborationConsistencyCheck(com.palantir.atlasdb.transaction.impl.consistency.ImmutableTimestampCorroborationConsistencyCheck) DefaultMetricsFilterEvaluationContext(com.palantir.atlasdb.transaction.impl.metrics.DefaultMetricsFilterEvaluationContext) SweepStatsKeyValueService(com.palantir.atlasdb.keyvalue.impl.SweepStatsKeyValueService) TimeLockClientConfig(com.palantir.atlasdb.config.TimeLockClientConfig) SimpleTimeDuration(com.palantir.lock.SimpleTimeDuration) LockServiceImpl(com.palantir.lock.impl.LockServiceImpl) AsyncInitializer(com.palantir.async.initializer.AsyncInitializer) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) ValidatingQueryRewritingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ValidatingQueryRewritingKeyValueService) AtlasDbVersion(com.palantir.atlasdb.versions.AtlasDbVersion) CompactorConfig(com.palantir.atlasdb.compact.CompactorConfig) ImmutableSweepBatchConfig(com.palantir.atlasdb.sweep.ImmutableSweepBatchConfig) BackgroundCompactor(com.palantir.atlasdb.compact.BackgroundCompactor) LockRequest(com.palantir.lock.LockRequest) MetadataCoordinationServiceMetrics(com.palantir.atlasdb.internalschema.metrics.MetadataCoordinationServiceMetrics) TargetedSweepInstallConfig(com.palantir.atlasdb.sweep.queue.config.TargetedSweepInstallConfig) LockServerConfigs(com.palantir.lock.LockServerConfigs) SweepConfig(com.palantir.atlasdb.config.SweepConfig) Clock(com.palantir.common.time.Clock) MetricRegistry(com.codahale.metrics.MetricRegistry) Callback(com.palantir.async.initializer.Callback) TargetedSweeper(com.palantir.atlasdb.sweep.queue.TargetedSweeper) TransactionSchemaManager(com.palantir.atlasdb.internalschema.TransactionSchemaManager) TransactionSchemaInstaller(com.palantir.atlasdb.internalschema.TransactionSchemaInstaller) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) SweepTableFactory(com.palantir.atlasdb.schema.generated.SweepTableFactory) BackgroundSweeperImpl(com.palantir.atlasdb.sweep.BackgroundSweeperImpl) Follower(com.palantir.atlasdb.cleaner.Follower) LockService(com.palantir.lock.LockService) TimeLockClient(com.palantir.lock.client.TimeLockClient) ManagedTimestampService(com.palantir.timestamp.ManagedTimestampService) UserAgents(com.palantir.conjure.java.api.config.service.UserAgents) LockClient(com.palantir.lock.LockClient) MultiTableSweepQueueWriter(com.palantir.atlasdb.sweep.queue.MultiTableSweepQueueWriter) ConflictTracer(com.palantir.atlasdb.debug.ConflictTracer) ConflictDetectionManager(com.palantir.atlasdb.transaction.impl.ConflictDetectionManager) ShouldRunBackgroundSweepSupplier(com.palantir.atlasdb.config.ShouldRunBackgroundSweepSupplier) DerivedSnapshotConfig(com.palantir.atlasdb.spi.DerivedSnapshotConfig) SweepStrategyManager(com.palantir.atlasdb.transaction.impl.SweepStrategyManager) StagedBuilderStyle(com.palantir.common.annotations.ImmutablesStyles.StagedBuilderStyle) LockRefreshingLockService(com.palantir.lock.client.LockRefreshingLockService) TimeLockClientFeedbackService(com.palantir.atlasdb.timelock.adjudicate.feedback.TimeLockClientFeedbackService) CheckAndSetCompatibility(com.palantir.atlasdb.keyvalue.api.CheckAndSetCompatibility) TransactionConfig(com.palantir.atlasdb.transaction.TransactionConfig) MetricsManager(com.palantir.atlasdb.util.MetricsManager) PTExecutors(com.palantir.common.concurrent.PTExecutors) TransactionServices(com.palantir.atlasdb.transaction.service.TransactionServices) LockWatchingCache(com.palantir.atlasdb.transaction.api.LockWatchingCache) SweepTaskRunner(com.palantir.atlasdb.sweep.SweepTaskRunner) ToLongFunction(java.util.function.ToLongFunction) ImmutableSet(com.google.common.collect.ImmutableSet) CoordinationService(com.palantir.atlasdb.coordination.CoordinationService) LockDiagnosticComponents(com.palantir.atlasdb.debug.LockDiagnosticComponents) DefaultCleanerBuilder(com.palantir.atlasdb.cleaner.DefaultCleanerBuilder) ProfilingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ProfilingKeyValueService) Collectors(java.util.stream.Collectors) ServerListConfig(com.palantir.atlasdb.config.ServerListConfig) AtlasDbMetricNames(com.palantir.atlasdb.AtlasDbMetricNames) List(java.util.List) Optional(java.util.Optional) ConsistencyCheckRunner(com.palantir.atlasdb.factory.startup.ConsistencyCheckRunner) SafeLoggerFactory(com.palantir.logsafe.logger.SafeLoggerFactory) Cleaner(com.palantir.atlasdb.cleaner.api.Cleaner) AtlasDbMetrics(com.palantir.atlasdb.util.AtlasDbMetrics) Output(com.palantir.common.annotation.Output) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) TimestampStoreInvalidator(com.palantir.timestamp.TimestampStoreInvalidator) AdjustableSweepBatchConfigSource(com.palantir.atlasdb.sweep.AdjustableSweepBatchConfigSource) Function(java.util.function.Function) SafeLogger(com.palantir.logsafe.logger.SafeLogger) AtlasDbConstraintCheckingMode(com.palantir.atlasdb.transaction.api.AtlasDbConstraintCheckingMode) SafeArg(com.palantir.logsafe.SafeArg) ImmutableList(com.google.common.collect.ImmutableList) Value(org.immutables.value.Value) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) AuxiliaryRemotingParameters(com.palantir.atlasdb.config.AuxiliaryRemotingParameters) TracingKeyValueService(com.palantir.atlasdb.keyvalue.impl.TracingKeyValueService) ImmutableTransactionConfig(com.palantir.atlasdb.transaction.ImmutableTransactionConfig) FreshTimestampSupplierAdapter(com.palantir.atlasdb.factory.timestamp.FreshTimestampSupplierAdapter) SweepStrategyManagers(com.palantir.atlasdb.transaction.impl.SweepStrategyManagers) BackgroundSweeperPerformanceLogger(com.palantir.atlasdb.sweep.BackgroundSweeperPerformanceLogger) NoOpLockWatchingCache(com.palantir.atlasdb.transaction.api.NoOpLockWatchingCache) TimestampCache(com.palantir.atlasdb.cache.TimestampCache) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) LambdaCallback(com.palantir.async.initializer.LambdaCallback) TransactionConstants(com.palantir.atlasdb.transaction.impl.TransactionConstants) SpecificTableSweeper(com.palantir.atlasdb.sweep.SpecificTableSweeper) LegacySweepMetrics(com.palantir.atlasdb.sweep.metrics.LegacySweepMetrics) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) AtlasDbRemotingConstants(com.palantir.atlasdb.http.AtlasDbRemotingConstants) CellsSweeper(com.palantir.atlasdb.sweep.CellsSweeper) VisibleForTesting(com.google.common.annotations.VisibleForTesting) DefaultTimestampCache(com.palantir.atlasdb.cache.DefaultTimestampCache) DialogueClients(com.palantir.dialogue.clients.DialogueClients) OldestTargetedSweepTrackedTimestamp(com.palantir.atlasdb.sweep.queue.OldestTargetedSweepTrackedTimestamp) Schema(com.palantir.atlasdb.table.description.Schema) Preconditions(com.palantir.logsafe.Preconditions) CleanupFollower(com.palantir.atlasdb.cleaner.CleanupFollower) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) MetricsManager(com.palantir.atlasdb.util.MetricsManager) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) MetricRegistry(com.codahale.metrics.MetricRegistry) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)

Example 3 with MetricsManager

use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.

the class LockWatchManagerImpl method create.

public static LockWatchManagerInternal create(MetricsManager metricsManager, Set<Schema> schemas, LockWatchStarter lockWatchingService, LockWatchCachingConfig config) {
    Set<LockWatchReference> referencesFromSchema = schemas.stream().map(Schema::getLockWatches).flatMap(Set::stream).collect(Collectors.toSet());
    Set<TableReference> watchedTablesFromSchema = referencesFromSchema.stream().map(schema -> schema.accept(LockWatchReferencesVisitor.INSTANCE)).collect(Collectors.toSet());
    CacheMetrics metrics = CacheMetrics.create(metricsManager);
    LockWatchEventCache eventCache = LockWatchEventCacheImpl.create(metrics);
    LockWatchValueScopingCache valueCache = LockWatchValueScopingCacheImpl.create(eventCache, metrics, config.cacheSize(), config.validationProbability(), watchedTablesFromSchema);
    return new LockWatchManagerImpl(referencesFromSchema, eventCache, valueCache, lockWatchingService);
}
Also used : SafeLoggerFactory(com.palantir.logsafe.logger.SafeLoggerFactory) ScheduledFuture(java.util.concurrent.ScheduledFuture) LockWatchRequest(com.palantir.atlasdb.timelock.api.LockWatchRequest) CommitUpdate(com.palantir.lock.watch.CommitUpdate) SafeLogger(com.palantir.logsafe.logger.SafeLogger) MetricsManager(com.palantir.atlasdb.util.MetricsManager) LockWatchEventCache(com.palantir.lock.watch.LockWatchEventCache) PTExecutors(com.palantir.common.concurrent.PTExecutors) LockWatchCache(com.palantir.lock.watch.LockWatchCache) TransactionsLockWatchUpdate(com.palantir.lock.watch.TransactionsLockWatchUpdate) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) LockWatchReference(com.palantir.lock.watch.LockWatchReferences.LockWatchReference) LockWatchValueScopingCacheImpl(com.palantir.atlasdb.keyvalue.api.cache.LockWatchValueScopingCacheImpl) LockWatchValueScopingCache(com.palantir.atlasdb.keyvalue.api.cache.LockWatchValueScopingCache) LockWatchVersion(com.palantir.lock.watch.LockWatchVersion) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) Collectors(java.util.stream.Collectors) LockWatchReferences(com.palantir.lock.watch.LockWatchReferences) TimeUnit(java.util.concurrent.TimeUnit) TransactionScopedCache(com.palantir.atlasdb.keyvalue.api.cache.TransactionScopedCache) LockWatchCachingConfig(com.palantir.atlasdb.keyvalue.api.LockWatchCachingConfig) UnsafeArg(com.palantir.logsafe.UnsafeArg) CacheMetrics(com.palantir.atlasdb.keyvalue.api.cache.CacheMetrics) LockWatchReferencesVisitor(com.palantir.lock.watch.LockWatchReferencesVisitor) LockWatchCacheImpl(com.palantir.lock.watch.LockWatchCacheImpl) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) LockWatchStarter(com.palantir.lock.client.LockWatchStarter) Schema(com.palantir.atlasdb.table.description.Schema) CacheMetrics(com.palantir.atlasdb.keyvalue.api.cache.CacheMetrics) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) LockWatchEventCache(com.palantir.lock.watch.LockWatchEventCache) Schema(com.palantir.atlasdb.table.description.Schema) LockWatchReference(com.palantir.lock.watch.LockWatchReferences.LockWatchReference) LockWatchValueScopingCache(com.palantir.atlasdb.keyvalue.api.cache.LockWatchValueScopingCache)

Example 4 with MetricsManager

use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.

the class MetadataCoordinationServiceMetricsTest method handlesMultitenancyCorrectly.

@Test
public void handlesMultitenancyCorrectly() {
    CoordinationService<InternalSchemaMetadata> otherService = mock(CoordinationService.class);
    MetricsManager otherManager = MetricsManagers.createForTests();
    TimestampService otherTimestampService = mock(TimestampService.class);
    MetadataCoordinationServiceMetrics.registerMetrics(otherManager, otherService, otherTimestampService);
    when(otherService.getLastKnownLocalValue()).thenReturn(Optional.of(ValueAndBound.of(Optional.empty(), TIMESTAMP_2)));
    assertThat(getGauge(metricsManager, AtlasDbMetricNames.COORDINATION_LAST_VALID_BOUND).getValue()).isEqualTo(TIMESTAMP_1);
    assertThat(getGauge(otherManager, AtlasDbMetricNames.COORDINATION_LAST_VALID_BOUND).getValue()).isEqualTo(TIMESTAMP_2);
}
Also used : InternalSchemaMetadata(com.palantir.atlasdb.internalschema.InternalSchemaMetadata) MetricsManager(com.palantir.atlasdb.util.MetricsManager) TimestampService(com.palantir.timestamp.TimestampService) Test(org.junit.Test)

Example 5 with MetricsManager

use of com.palantir.atlasdb.util.MetricsManager in project atlasdb by palantir.

the class CassandraServiceTest method clientPoolWithParams.

private CassandraService clientPoolWithParams(Set<CassandraServer> servers, Set<CassandraServer> serversInPool, double weighting) {
    config = ImmutableCassandraKeyValueServiceConfig.builder().credentials(ImmutableCassandraCredentialsConfig.builder().username("username").password("password").build()).localHostWeighting(weighting).consecutiveAbsencesBeforePoolRemoval(1).keyspace("ks").build();
    Refreshable<CassandraKeyValueServiceRuntimeConfig> runtimeConfig = Refreshable.only(ImmutableCassandraKeyValueServiceRuntimeConfig.builder().servers(ImmutableDefaultConfig.builder().addAllThriftHosts(servers.stream().map(CassandraServer::proxy).collect(Collectors.toSet())).build()).replicationFactor(3).build());
    blacklist = new Blacklist(config, runtimeConfig.map(CassandraKeyValueServiceRuntimeConfig::unresponsiveHostBackoffTimeSeconds));
    MetricsManager metricsManager = MetricsManagers.createForTests();
    CassandraService service = new CassandraService(metricsManager, config, runtimeConfig, blacklist, new CassandraClientPoolMetrics(metricsManager));
    service.cacheInitialCassandraHosts();
    serversInPool.forEach(service::addPool);
    return service;
}
Also used : ImmutableCassandraKeyValueServiceRuntimeConfig(com.palantir.atlasdb.cassandra.ImmutableCassandraKeyValueServiceRuntimeConfig) CassandraKeyValueServiceRuntimeConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceRuntimeConfig) MetricsManager(com.palantir.atlasdb.util.MetricsManager) Blacklist(com.palantir.atlasdb.keyvalue.cassandra.Blacklist)

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