Search in sources :

Example 6 with UserAgent

use of com.palantir.conjure.java.api.config.service.UserAgent in project atlasdb by palantir.

the class DefaultLockAndTimestampServiceFactory method getLockAndTimestampServices.

private static LockAndTimestampServices getLockAndTimestampServices(MetricsManager metricsManager, Refreshable<ServerListConfig> timelockServerListConfig, UserAgent userAgent, String timelockNamespace, Optional<LockDiagnosticComponents> lockDiagnosticComponents, ReloadingFactory reloadingFactory, Optional<TimeLockFeedbackBackgroundTask> timeLockFeedbackBackgroundTask, Optional<TimeLockRequestBatcherProviders> timelockRequestBatcherProviders, Set<Schema> schemas, LockWatchCachingConfig cachingConfig) {
    AtlasDbDialogueServiceProvider serviceProvider = AtlasDbDialogueServiceProvider.create(timelockServerListConfig, reloadingFactory, userAgent, metricsManager.getTaggedRegistry());
    LockRpcClient lockRpcClient = serviceProvider.getLockRpcClient();
    LockService lockService = AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), LockService.class, RemoteLockServiceAdapter.create(lockRpcClient, timelockNamespace));
    ConjureTimelockService conjureTimelockService = serviceProvider.getConjureTimelockService();
    TimelockRpcClient timelockClient = serviceProvider.getTimelockRpcClient();
    // TODO(fdesouza): Remove this once PDS-95791 is resolved.
    ConjureTimelockService withDiagnosticsConjureTimelockService = lockDiagnosticComponents.<ConjureTimelockService>map(components -> new LockDiagnosticConjureTimelockService(conjureTimelockService, components.clientLockDiagnosticCollector(), components.localLockTracker())).orElse(conjureTimelockService);
    NamespacedTimelockRpcClient namespacedTimelockRpcClient = new DefaultNamespacedTimelockRpcClient(timelockClient, timelockNamespace);
    LeaderElectionReportingTimelockService leaderElectionReportingTimelockService = LeaderElectionReportingTimelockService.create(withDiagnosticsConjureTimelockService, timelockNamespace);
    timeLockFeedbackBackgroundTask.ifPresent(task -> task.registerLeaderElectionStatistics(leaderElectionReportingTimelockService));
    NamespacedConjureTimelockService namespacedConjureTimelockService = TimestampCorroboratingTimelockService.create(timelockNamespace, metricsManager.getTaggedRegistry(), leaderElectionReportingTimelockService);
    NamespacedConjureLockWatchingService lockWatchingService = new NamespacedConjureLockWatchingService(serviceProvider.getConjureLockWatchingService(), timelockNamespace);
    Supplier<InternalMultiClientConjureTimelockService> multiClientTimelockServiceSupplier = getMultiClientTimelockServiceSupplier(serviceProvider);
    Supplier<Optional<RequestBatchersFactory.MultiClientRequestBatchers>> requestBatcherProvider = () -> timelockRequestBatcherProviders.map(batcherProviders -> ImmutableMultiClientRequestBatchers.of(batcherProviders.commitTimestamps().getBatcher(multiClientTimelockServiceSupplier), batcherProviders.startTransactions().getBatcher(multiClientTimelockServiceSupplier)));
    TimeLockHelperServices timeLockHelperServices = TimeLockHelperServices.create(timelockNamespace, metricsManager, schemas, lockWatchingService, cachingConfig, requestBatcherProvider);
    LockWatchManagerInternal lockWatchManager = timeLockHelperServices.lockWatchManager();
    RemoteTimelockServiceAdapter remoteTimelockServiceAdapter = RemoteTimelockServiceAdapter.create(namespacedTimelockRpcClient, namespacedConjureTimelockService, getLeaderTimeGetter(timelockNamespace, timelockRequestBatcherProviders, namespacedConjureTimelockService, multiClientTimelockServiceSupplier), timeLockHelperServices.requestBatchersFactory());
    TimestampManagementService timestampManagementService = new RemoteTimestampManagementAdapter(serviceProvider.getTimestampManagementRpcClient(), timelockNamespace);
    return ImmutableLockAndTimestampServices.builder().lock(lockService).timestamp(new TimelockTimestampServiceAdapter(remoteTimelockServiceAdapter)).timestampManagement(timestampManagementService).timelock(remoteTimelockServiceAdapter).lockWatcher(lockWatchManager).addResources(remoteTimelockServiceAdapter::close).addResources(lockWatchManager::close).build();
}
Also used : ServerListConfigs(com.palantir.atlasdb.config.ServerListConfigs) SafeIllegalStateException(com.palantir.logsafe.exceptions.SafeIllegalStateException) AuthenticatedInternalMultiClientConjureTimelockService(com.palantir.lock.client.AuthenticatedInternalMultiClientConjureTimelockService) LeaderConfig(com.palantir.atlasdb.config.LeaderConfig) LockRefreshingLockService(com.palantir.lock.client.LockRefreshingLockService) ClientErrorException(javax.ws.rs.ClientErrorException) NamespacedConjureTimelockService(com.palantir.lock.client.NamespacedConjureTimelockService) TimelockTimestampServiceAdapter(com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter) MetricsManager(com.palantir.atlasdb.util.MetricsManager) NamespacedTimelockRpcClient(com.palantir.lock.v2.NamespacedTimelockRpcClient) TimeLockRequestBatcherProviders(com.palantir.atlasdb.config.TimeLockRequestBatcherProviders) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) Duration(java.time.Duration) TimestampService(com.palantir.timestamp.TimestampService) TimelockRpcClient(com.palantir.lock.v2.TimelockRpcClient) Refreshable(com.palantir.refreshable.Refreshable) TimestampManagementService(com.palantir.timestamp.TimestampManagementService) LockDiagnosticComponents(com.palantir.atlasdb.debug.LockDiagnosticComponents) ReloadingFactory(com.palantir.dialogue.clients.DialogueClients.ReloadingFactory) AtlasDbHttpClients(com.palantir.atlasdb.http.AtlasDbHttpClients) TimeLockFeedbackBackgroundTask(com.palantir.lock.client.metrics.TimeLockFeedbackBackgroundTask) SafeIllegalArgumentException(com.palantir.logsafe.exceptions.SafeIllegalArgumentException) Set(java.util.Set) ServerListConfig(com.palantir.atlasdb.config.ServerListConfig) ReferenceTrackingWrapper(com.palantir.lock.client.ReferenceTrackingWrapper) LockRpcClient(com.palantir.lock.LockRpcClient) LeaderTimeCoalescingBatcher(com.palantir.lock.client.LeaderTimeCoalescingBatcher) LockWatchCachingConfig(com.palantir.atlasdb.keyvalue.api.LockWatchCachingConfig) NamespacedConjureLockWatchingService(com.palantir.lock.client.NamespacedConjureLockWatchingService) ImmutableMultiClientRequestBatchers(com.palantir.lock.client.ImmutableMultiClientRequestBatchers) TimestampRange(com.palantir.timestamp.TimestampRange) InternalMultiClientConjureTimelockService(com.palantir.lock.client.InternalMultiClientConjureTimelockService) Optional(java.util.Optional) TimeLockClientConfig(com.palantir.atlasdb.config.TimeLockClientConfig) InstrumentedTimelockService(com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService) LockDiagnosticConjureTimelockService(com.palantir.atlasdb.debug.LockDiagnosticConjureTimelockService) RemotingClientConfigs(com.palantir.atlasdb.config.RemotingClientConfigs) ImmutableServerListConfig(com.palantir.atlasdb.config.ImmutableServerListConfig) LeadershipCoordinator(com.palantir.leader.proxy.LeadershipCoordinator) Iterables(com.google.common.collect.Iterables) SafeLoggerFactory(com.palantir.logsafe.logger.SafeLoggerFactory) ProfilingTimelockService(com.palantir.lock.client.ProfilingTimelockService) AtlasDbMetrics(com.palantir.atlasdb.util.AtlasDbMetrics) ConjureTimelockService(com.palantir.atlasdb.timelock.api.ConjureTimelockService) RequestBatchersFactory(com.palantir.lock.client.RequestBatchersFactory) RemoteTimestampManagementAdapter(com.palantir.timestamp.RemoteTimestampManagementAdapter) TimestampStoreInvalidator(com.palantir.timestamp.TimestampStoreInvalidator) CompletableFuture(java.util.concurrent.CompletableFuture) Supplier(java.util.function.Supplier) LeaderTimeGetter(com.palantir.lock.client.LeaderTimeGetter) SafeLogger(com.palantir.logsafe.logger.SafeLogger) RemoteTimelockServiceAdapter(com.palantir.lock.client.RemoteTimelockServiceAdapter) LegacyTimelockService(com.palantir.lock.impl.LegacyTimelockService) AuxiliaryRemotingParameters(com.palantir.atlasdb.config.AuxiliaryRemotingParameters) Suppliers(com.google.common.base.Suppliers) RemoteLockServiceAdapter(com.palantir.lock.client.RemoteLockServiceAdapter) OptionalResolver(com.palantir.util.OptionalResolver) TimestampCorroboratingTimelockService(com.palantir.lock.client.TimestampCorroboratingTimelockService) AwaitingLeadershipProxy(com.palantir.leader.proxy.AwaitingLeadershipProxy) NamespaceAgnosticLockRpcClient(com.palantir.lock.NamespaceAgnosticLockRpcClient) UnknownRemoteException(com.palantir.conjure.java.api.errors.UnknownRemoteException) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) LockWatchManagerInternal(com.palantir.atlasdb.keyvalue.api.watch.LockWatchManagerInternal) TimelockService(com.palantir.lock.v2.TimelockService) Consumer(java.util.function.Consumer) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) TimeLockMigrator(com.palantir.atlasdb.factory.startup.TimeLockMigrator) LockService(com.palantir.lock.LockService) NamespacedCoalescingLeaderTimeGetter(com.palantir.lock.client.NamespacedCoalescingLeaderTimeGetter) TimeLockClient(com.palantir.lock.client.TimeLockClient) ManagedTimestampService(com.palantir.timestamp.ManagedTimestampService) DefaultNamespacedTimelockRpcClient(com.palantir.lock.v2.DefaultNamespacedTimelockRpcClient) LocalPaxosServices(com.palantir.atlasdb.factory.Leaders.LocalPaxosServices) LegacyLeaderTimeGetter(com.palantir.lock.client.LegacyLeaderTimeGetter) Schema(com.palantir.atlasdb.table.description.Schema) PingableLeader(com.palantir.leader.PingableLeader) LeaderElectionReportingTimelockService(com.palantir.lock.client.LeaderElectionReportingTimelockService) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) TimelockTimestampServiceAdapter(com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter) AuthenticatedInternalMultiClientConjureTimelockService(com.palantir.lock.client.AuthenticatedInternalMultiClientConjureTimelockService) InternalMultiClientConjureTimelockService(com.palantir.lock.client.InternalMultiClientConjureTimelockService) RemoteTimestampManagementAdapter(com.palantir.timestamp.RemoteTimestampManagementAdapter) LockRefreshingLockService(com.palantir.lock.client.LockRefreshingLockService) LockService(com.palantir.lock.LockService) Optional(java.util.Optional) LockRpcClient(com.palantir.lock.LockRpcClient) NamespaceAgnosticLockRpcClient(com.palantir.lock.NamespaceAgnosticLockRpcClient) NamespacedTimelockRpcClient(com.palantir.lock.v2.NamespacedTimelockRpcClient) TimelockRpcClient(com.palantir.lock.v2.TimelockRpcClient) DefaultNamespacedTimelockRpcClient(com.palantir.lock.v2.DefaultNamespacedTimelockRpcClient) LockWatchManagerInternal(com.palantir.atlasdb.keyvalue.api.watch.LockWatchManagerInternal) RemoteTimelockServiceAdapter(com.palantir.lock.client.RemoteTimelockServiceAdapter) RequestBatchersFactory(com.palantir.lock.client.RequestBatchersFactory) NamespacedConjureLockWatchingService(com.palantir.lock.client.NamespacedConjureLockWatchingService) NamespacedTimelockRpcClient(com.palantir.lock.v2.NamespacedTimelockRpcClient) DefaultNamespacedTimelockRpcClient(com.palantir.lock.v2.DefaultNamespacedTimelockRpcClient) LockDiagnosticConjureTimelockService(com.palantir.atlasdb.debug.LockDiagnosticConjureTimelockService) NamespacedConjureTimelockService(com.palantir.lock.client.NamespacedConjureTimelockService) TimestampManagementService(com.palantir.timestamp.TimestampManagementService) AuthenticatedInternalMultiClientConjureTimelockService(com.palantir.lock.client.AuthenticatedInternalMultiClientConjureTimelockService) NamespacedConjureTimelockService(com.palantir.lock.client.NamespacedConjureTimelockService) InternalMultiClientConjureTimelockService(com.palantir.lock.client.InternalMultiClientConjureTimelockService) LockDiagnosticConjureTimelockService(com.palantir.atlasdb.debug.LockDiagnosticConjureTimelockService) ConjureTimelockService(com.palantir.atlasdb.timelock.api.ConjureTimelockService) DefaultNamespacedTimelockRpcClient(com.palantir.lock.v2.DefaultNamespacedTimelockRpcClient) LeaderElectionReportingTimelockService(com.palantir.lock.client.LeaderElectionReportingTimelockService)

Example 7 with UserAgent

use of com.palantir.conjure.java.api.config.service.UserAgent in project atlasdb by palantir.

the class Leaders method createInstrumentedLocalServices.

public static LocalPaxosServices createInstrumentedLocalServices(MetricsManager metricsManager, LeaderConfig config, RemotePaxosServerSpec remotePaxosServerSpec, Supplier<RemotingClientConfig> remotingClientConfig, UserAgent userAgent, LeadershipObserver leadershipObserver) {
    UUID leaderUuid = UUID.randomUUID();
    PaxosLeadershipEventRecorder leadershipEventRecorder = PaxosLeadershipEventRecorder.create(metricsManager.getTaggedRegistry(), leaderUuid.toString(), leadershipObserver, ImmutableList.of());
    PaxosAcceptor ourAcceptor = AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), PaxosAcceptor.class, PaxosAcceptorImpl.newAcceptor(config.acceptorLogDir().getPath()));
    PaxosLearner ourLearner = AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), PaxosLearner.class, PaxosLearnerImpl.newLearner(config.learnerLogDir().getPath(), leadershipEventRecorder));
    Optional<TrustContext> trustContext = ServiceCreator.createTrustContext(config.sslConfiguration());
    List<PaxosLearner> learners = createProxyAndLocalList(ourLearner, remotePaxosServerSpec.remoteLearnerUris(), remotingClientConfig, trustContext, PaxosLearner.class, userAgent);
    List<PaxosLearner> remoteLearners = learners.stream().filter(learner -> !learner.equals(ourLearner)).collect(ImmutableList.toImmutableList());
    PaxosLearnerNetworkClient learnerNetworkClient = SingleLeaderLearnerNetworkClient.createLegacy(ourLearner, remoteLearners, config.quorumSize(), createExecutorsForService(metricsManager, learners, "knowledge-update"), PaxosConstants.CANCEL_REMAINING_CALLS);
    List<PaxosAcceptor> acceptors = createProxyAndLocalList(ourAcceptor, remotePaxosServerSpec.remoteAcceptorUris(), remotingClientConfig, trustContext, PaxosAcceptor.class, userAgent);
    PaxosAcceptorNetworkClient acceptorNetworkClient = SingleLeaderAcceptorNetworkClient.createLegacy(acceptors, config.quorumSize(), createExecutorsForService(metricsManager, acceptors, "latest-round-verifier"), PaxosConstants.CANCEL_REMAINING_CALLS);
    List<LeaderPingerContext<PingableLeader>> otherLeaders = generatePingables(remotePaxosServerSpec.remoteLeaderUris(), remotingClientConfig, trustContext, userAgent);
    LeaderPinger leaderPinger = SingleLeaderPinger.createLegacy(createExecutorsForService(metricsManager, otherLeaders, "leader-ping"), config.leaderPingResponseWait(), leaderUuid, PaxosConstants.CANCEL_REMAINING_CALLS);
    LeaderElectionService uninstrumentedLeaderElectionService = new LeaderElectionServiceBuilder().leaderUuid(leaderUuid).knowledge(ourLearner).eventRecorder(leadershipEventRecorder).randomWaitBeforeProposingLeadership(config.randomWaitBeforeProposingLeadership()).pingRate(config.pingRate()).leaderPinger(leaderPinger).acceptorClient(acceptorNetworkClient).learnerClient(learnerNetworkClient).decorateProposer(proposer -> AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), PaxosProposer.class, proposer)).leaderAddressCacheTtl(config.leaderAddressCacheTtl()).build();
    LeaderElectionService leaderElectionService = AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), LeaderElectionService.class, uninstrumentedLeaderElectionService);
    PingableLeader pingableLeader = AtlasDbMetrics.instrumentTimed(metricsManager.getRegistry(), PingableLeader.class, new LocalPingableLeader(ourLearner, leaderUuid));
    List<PingableLeader> remotePingableLeaders = otherLeaders.stream().map(LeaderPingerContext::pinger).collect(Collectors.toList());
    BatchingLeaderElectionService batchingLeaderElectionService = new BatchingLeaderElectionService(leaderElectionService);
    return ImmutableLocalPaxosServices.builder().ourAcceptor(ourAcceptor).ourLearner(ourLearner).leaderElectionService(batchingLeaderElectionService).leadershipCoordinator(LeadershipCoordinator.create(batchingLeaderElectionService)).localPingableLeader(pingableLeader).remotePingableLeaders(remotePingableLeaders).build();
}
Also used : PaxosLearnerImpl(com.palantir.paxos.PaxosLearnerImpl) LeaderConfig(com.palantir.atlasdb.config.LeaderConfig) PaxosLearner(com.palantir.paxos.PaxosLearner) BatchingLeaderElectionService(com.palantir.leader.BatchingLeaderElectionService) TrustContext(com.palantir.conjure.java.config.ssl.TrustContext) MetricsManager(com.palantir.atlasdb.util.MetricsManager) PTExecutors(com.palantir.common.concurrent.PTExecutors) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) Map(java.util.Map) NotCurrentLeaderExceptionMapper(com.palantir.atlasdb.http.NotCurrentLeaderExceptionMapper) PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) PaxosLeadershipEventRecorder(com.palantir.leader.PaxosLeadershipEventRecorder) URI(java.net.URI) SingleLeaderLearnerNetworkClient(com.palantir.paxos.SingleLeaderLearnerNetworkClient) LeaderElectionService(com.palantir.leader.LeaderElectionService) LeaderElectionServiceBuilder(com.palantir.leader.LeaderElectionServiceBuilder) LeaderPinger(com.palantir.paxos.LeaderPinger) ImmutableSet(com.google.common.collect.ImmutableSet) SingleLeaderPinger(com.palantir.paxos.SingleLeaderPinger) KeyedStream(com.palantir.common.streams.KeyedStream) Collection(java.util.Collection) AtlasDbHttpClients(com.palantir.atlasdb.http.AtlasDbHttpClients) ImmutableLeaderPingerContext(com.palantir.paxos.ImmutableLeaderPingerContext) Set(java.util.Set) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) Optional(java.util.Optional) RemotingClientConfigs(com.palantir.atlasdb.config.RemotingClientConfigs) LeadershipCoordinator(com.palantir.leader.proxy.LeadershipCoordinator) Iterables(com.google.common.collect.Iterables) AtlasDbMetrics(com.palantir.atlasdb.util.AtlasDbMetrics) LocalPingableLeader(com.palantir.leader.LocalPingableLeader) HashMap(java.util.HashMap) LeaderPingerContext(com.palantir.paxos.LeaderPingerContext) PaxosLearnerNetworkClient(com.palantir.paxos.PaxosLearnerNetworkClient) Supplier(java.util.function.Supplier) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) Value(org.immutables.value.Value) AuxiliaryRemotingParameters(com.palantir.atlasdb.config.AuxiliaryRemotingParameters) ExecutorService(java.util.concurrent.ExecutorService) HostAndPort(com.google.common.net.HostAndPort) SingleLeaderAcceptorNetworkClient(com.palantir.paxos.SingleLeaderAcceptorNetworkClient) Consumer(java.util.function.Consumer) PaxosAcceptorImpl(com.palantir.paxos.PaxosAcceptorImpl) PaxosProposer(com.palantir.paxos.PaxosProposer) PaxosAcceptorNetworkClient(com.palantir.paxos.PaxosAcceptorNetworkClient) RemotingClientConfig(com.palantir.atlasdb.config.RemotingClientConfig) LeadershipObserver(com.palantir.leader.LeadershipObserver) PaxosConstants(com.palantir.paxos.PaxosConstants) PingableLeader(com.palantir.leader.PingableLeader) PaxosAcceptor(com.palantir.paxos.PaxosAcceptor) ImmutableLeaderPingerContext(com.palantir.paxos.ImmutableLeaderPingerContext) LeaderPingerContext(com.palantir.paxos.LeaderPingerContext) PaxosAcceptorNetworkClient(com.palantir.paxos.PaxosAcceptorNetworkClient) PaxosProposer(com.palantir.paxos.PaxosProposer) LeaderPinger(com.palantir.paxos.LeaderPinger) SingleLeaderPinger(com.palantir.paxos.SingleLeaderPinger) LocalPingableLeader(com.palantir.leader.LocalPingableLeader) PaxosLearner(com.palantir.paxos.PaxosLearner) PaxosLearnerNetworkClient(com.palantir.paxos.PaxosLearnerNetworkClient) LeaderElectionServiceBuilder(com.palantir.leader.LeaderElectionServiceBuilder) BatchingLeaderElectionService(com.palantir.leader.BatchingLeaderElectionService) LocalPingableLeader(com.palantir.leader.LocalPingableLeader) PingableLeader(com.palantir.leader.PingableLeader) BatchingLeaderElectionService(com.palantir.leader.BatchingLeaderElectionService) LeaderElectionService(com.palantir.leader.LeaderElectionService) PaxosLeadershipEventRecorder(com.palantir.leader.PaxosLeadershipEventRecorder) UUID(java.util.UUID) TrustContext(com.palantir.conjure.java.config.ssl.TrustContext)

Example 8 with UserAgent

use of com.palantir.conjure.java.api.config.service.UserAgent in project atlasdb by palantir.

the class TimeLockTestUtils method createTransactionManager.

static TransactionManagerContext createTransactionManager(TestableTimelockCluster cluster, String agent, AtlasDbRuntimeConfig runtimeConfigTemplate, ImmutableAtlasDbConfig.Builder installConfigTemplate, Optional<LockDiagnosticComponents> diagnosticComponents, Schema... schemas) {
    List<String> serverUris = cluster.servers().stream().map(server -> server.serverHolder().getTimelockUri()).collect(Collectors.toList());
    AtlasDbConfig config = installConfigTemplate.namespace(agent).keyValueService(new InMemoryAtlasDbConfig()).timelock(ImmutableTimeLockClientConfig.builder().serversList(ImmutableServerListConfig.builder().servers(serverUris).sslConfiguration(SslConfiguration.of(Paths.get("var/security/trustStore.jks"))).build()).build()).build();
    AtlasDbRuntimeConfig runtimeConfig = ImmutableAtlasDbRuntimeConfig.copyOf(runtimeConfigTemplate).withRemotingClient(RemotingClientConfigs.DEFAULT);
    TransactionManager transactionManager = TransactionManagers.builder().config(config).userAgent(UserAgent.of(UserAgent.Agent.of("u" + agent, "0.0.0"))).globalMetricsRegistry(new MetricRegistry()).globalTaggedMetricRegistry(DefaultTaggedMetricRegistry.getDefault()).runtimeConfigSupplier(() -> Optional.of(runtimeConfig)).lockDiagnosticComponents(diagnosticComponents).addSchemas(schemas).build().serializable();
    return ImmutableTransactionManagerContext.builder().transactionManager(transactionManager).install(config).runtime(runtimeConfig).build();
}
Also used : ImmutableServerListConfig(com.palantir.atlasdb.config.ImmutableServerListConfig) MetricRegistry(com.codahale.metrics.MetricRegistry) ImmutableTimeLockClientConfig(com.palantir.atlasdb.config.ImmutableTimeLockClientConfig) LockDiagnosticComponents(com.palantir.atlasdb.debug.LockDiagnosticComponents) SslConfiguration(com.palantir.conjure.java.api.config.ssl.SslConfiguration) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) TransactionManagers(com.palantir.atlasdb.factory.TransactionManagers) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) ImmutableAtlasDbRuntimeConfig(com.palantir.atlasdb.config.ImmutableAtlasDbRuntimeConfig) List(java.util.List) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) Paths(java.nio.file.Paths) Value(org.immutables.value.Value) Optional(java.util.Optional) RemotingClientConfigs(com.palantir.atlasdb.config.RemotingClientConfigs) Schema(com.palantir.atlasdb.table.description.Schema) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) MetricRegistry(com.codahale.metrics.MetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) ImmutableAtlasDbRuntimeConfig(com.palantir.atlasdb.config.ImmutableAtlasDbRuntimeConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig)

Example 9 with UserAgent

use of com.palantir.conjure.java.api.config.service.UserAgent in project atlasdb by palantir.

the class TimeLockDialogueServiceProvider method create.

public static TimeLockDialogueServiceProvider create(TaggedMetricRegistry taggedMetricRegistry, DialogueClients.ReloadingFactory baseFactory, ServerListConfig serverListConfig, AuxiliaryRemotingParameters parameters) {
    UserAgent versionedAgent = parameters.userAgent().addAgent(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT_AGENT);
    Map<String, RemoteServiceConfiguration> remoteServiceConfigurations = createRemoteServiceConfigurations(serverListConfig, versionedAgent, parameters);
    DialogueClients.ReloadingFactory reloadingFactory = decorate(baseFactory, Refreshable.only(remoteServiceConfigurations)).withUserAgent(versionedAgent);
    return new TimeLockDialogueServiceProvider(reloadingFactory, taggedMetricRegistry);
}
Also used : UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) ImmutableRemoteServiceConfiguration(com.palantir.atlasdb.http.v2.ImmutableRemoteServiceConfiguration) RemoteServiceConfiguration(com.palantir.atlasdb.http.v2.RemoteServiceConfiguration) DialogueClients(com.palantir.dialogue.clients.DialogueClients)

Example 10 with UserAgent

use of com.palantir.conjure.java.api.config.service.UserAgent in project conjure-java-runtime by palantir.

the class UserAgentTest method testUserAgent_augmentedByHttpRemotingAndServiceComponents.

@Test
public void testUserAgent_augmentedByHttpRemotingAndServiceComponents() throws Exception {
    TestService service = JaxRsClient.create(TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(endpointUri));
    service.string();
    RecordedRequest request = server.takeRequest();
    String dialogueVersion = Channel.class.getPackage().getImplementationVersion();
    UserAgent expected = AGENT.addAgent(UserAgent.Agent.of("TestService", "0.0.0")).addAgent(UserAgent.Agent.of("dialogue", MoreObjects.firstNonNull(dialogueVersion, "0.0.0")));
    assertThat(request.getHeader("User-Agent")).isEqualTo(UserAgents.format(expected));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) TestService(com.palantir.conjure.java.client.jaxrs.TestService) Channel(com.palantir.dialogue.Channel) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) HostMetricsRegistry(com.palantir.conjure.java.okhttp.HostMetricsRegistry) Test(org.junit.Test)

Aggregations

UserAgent (com.palantir.conjure.java.api.config.service.UserAgent)11 DialogueClients (com.palantir.dialogue.clients.DialogueClients)4 RemotingClientConfigs (com.palantir.atlasdb.config.RemotingClientConfigs)3 Map (java.util.Map)3 Optional (java.util.Optional)3 Iterables (com.google.common.collect.Iterables)2 AtlasDbConfig (com.palantir.atlasdb.config.AtlasDbConfig)2 AtlasDbRuntimeConfig (com.palantir.atlasdb.config.AtlasDbRuntimeConfig)2 AuxiliaryRemotingParameters (com.palantir.atlasdb.config.AuxiliaryRemotingParameters)2 ImmutableServerListConfig (com.palantir.atlasdb.config.ImmutableServerListConfig)2 LeaderConfig (com.palantir.atlasdb.config.LeaderConfig)2 LockDiagnosticComponents (com.palantir.atlasdb.debug.LockDiagnosticComponents)2 AtlasDbHttpClients (com.palantir.atlasdb.http.AtlasDbHttpClients)2 Schema (com.palantir.atlasdb.table.description.Schema)2 AtlasDbMetrics (com.palantir.atlasdb.util.AtlasDbMetrics)2 MetricsManager (com.palantir.atlasdb.util.MetricsManager)2 ReloadingFactory (com.palantir.dialogue.clients.DialogueClients.ReloadingFactory)2 PingableLeader (com.palantir.leader.PingableLeader)2 LeadershipCoordinator (com.palantir.leader.proxy.LeadershipCoordinator)2 SafeIllegalArgumentException (com.palantir.logsafe.exceptions.SafeIllegalArgumentException)2