Search in sources :

Example 1 with ServiceCreator

use of com.palantir.atlasdb.factory.ServiceCreator in project atlasdb by palantir.

the class TransactionPostMortemRunner method createRpcClient.

private static LockDiagnosticInfoService createRpcClient(AtlasDbConfig config, Refreshable<AtlasDbRuntimeConfig> runtimeConfigSupplier) {
    Refreshable<ServerListConfig> serverListConfigSupplier = getServerListConfigSupplierForTimeLock(config, runtimeConfigSupplier);
    timelockNamespace(config);
    ServiceCreator serviceCreator = ServiceCreator.withPayloadLimiter(new MetricsManager(new MetricRegistry(), new DefaultTaggedMetricRegistry(), _unused -> true), serverListConfigSupplier, UserAgent.of(UserAgent.Agent.of("agent", "0.0.0")), () -> runtimeConfigSupplier.get().remotingClient());
    return serviceCreator.createService(LockDiagnosticInfoService.class);
}
Also used : ServerListConfigs(com.palantir.atlasdb.config.ServerListConfigs) SafeLoggerFactory(com.palantir.logsafe.logger.SafeLoggerFactory) ImmutableTimeLockClientConfig(com.palantir.atlasdb.config.ImmutableTimeLockClientConfig) ConjureLockDescriptor(com.palantir.atlasdb.timelock.api.ConjureLockDescriptor) LockDigest(com.palantir.atlasdb.debug.FullDiagnosticDigest.LockDigest) SafeLogger(com.palantir.logsafe.logger.SafeLogger) SafeArg(com.palantir.logsafe.SafeArg) ClientLockDiagnosticDigest(com.palantir.atlasdb.debug.ClientLockDiagnosticCollector.ClientLockDiagnosticDigest) MetricsManager(com.palantir.atlasdb.util.MetricsManager) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) Map(java.util.Map) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) OptionalResolver(com.palantir.util.OptionalResolver) Persistable(com.palantir.common.persist.Persistable) Refreshable(com.palantir.refreshable.Refreshable) MetricRegistry(com.codahale.metrics.MetricRegistry) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) KeyedStream(com.palantir.common.streams.KeyedStream) Collection(java.util.Collection) Set(java.util.Set) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) UUID(java.util.UUID) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ServerListConfig(com.palantir.atlasdb.config.ServerListConfig) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) List(java.util.List) ServiceCreator(com.palantir.atlasdb.factory.ServiceCreator) Optional(java.util.Optional) TimeLockClientConfig(com.palantir.atlasdb.config.TimeLockClientConfig) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) ServerListConfig(com.palantir.atlasdb.config.ServerListConfig) ServiceCreator(com.palantir.atlasdb.factory.ServiceCreator) MetricsManager(com.palantir.atlasdb.util.MetricsManager) MetricRegistry(com.codahale.metrics.MetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)

Example 2 with ServiceCreator

use of com.palantir.atlasdb.factory.ServiceCreator in project atlasdb by palantir.

the class ShortAndLongTimeoutServicesTest method createInvokesCorrectMethodsOnServiceCreator.

@Test
public void createInvokesCorrectMethodsOnServiceCreator() {
    Object shortTimeout = new Object();
    Object longTimeout = new Object();
    ServiceCreator serviceCreator = mock(ServiceCreator.class);
    when(serviceCreator.createServiceWithShortTimeout(any())).thenReturn(shortTimeout);
    when(serviceCreator.createService(any())).thenReturn(longTimeout);
    ShortAndLongTimeoutServices<Object> services = ShortAndLongTimeoutServices.create(serviceCreator, Object.class);
    assertThat(services.shortTimeout()).isEqualTo(shortTimeout);
    assertThat(services.longTimeout()).isEqualTo(longTimeout);
    verify(serviceCreator).createService(Object.class);
    verify(serviceCreator).createServiceWithShortTimeout(Object.class);
    verifyNoMoreInteractions(serviceCreator);
}
Also used : ServiceCreator(com.palantir.atlasdb.factory.ServiceCreator) Test(org.junit.Test)

Aggregations

ServiceCreator (com.palantir.atlasdb.factory.ServiceCreator)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 AtlasDbConfig (com.palantir.atlasdb.config.AtlasDbConfig)1 AtlasDbRuntimeConfig (com.palantir.atlasdb.config.AtlasDbRuntimeConfig)1 ImmutableTimeLockClientConfig (com.palantir.atlasdb.config.ImmutableTimeLockClientConfig)1 ServerListConfig (com.palantir.atlasdb.config.ServerListConfig)1 ServerListConfigs (com.palantir.atlasdb.config.ServerListConfigs)1 TimeLockClientConfig (com.palantir.atlasdb.config.TimeLockClientConfig)1 ClientLockDiagnosticDigest (com.palantir.atlasdb.debug.ClientLockDiagnosticCollector.ClientLockDiagnosticDigest)1 LockDigest (com.palantir.atlasdb.debug.FullDiagnosticDigest.LockDigest)1 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)1 ConjureLockDescriptor (com.palantir.atlasdb.timelock.api.ConjureLockDescriptor)1 TransactionManager (com.palantir.atlasdb.transaction.api.TransactionManager)1 MetricsManager (com.palantir.atlasdb.util.MetricsManager)1 Persistable (com.palantir.common.persist.Persistable)1 KeyedStream (com.palantir.common.streams.KeyedStream)1 UserAgent (com.palantir.conjure.java.api.config.service.UserAgent)1 SafeArg (com.palantir.logsafe.SafeArg)1