Search in sources :

Example 1 with UserAgent

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

the class AtlasDbEteServer method getRemoteTimeLockManagementService.

private TimeLockManagementService getRemoteTimeLockManagementService(Refreshable<ServerListConfig> serverListConfig, TaggedMetricRegistry taggedMetrics) {
    UserAgent userAgent = UserAgent.of(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT_AGENT);
    DialogueClients.ReloadingFactory reloadingFactory = DialogueClients.create(Refreshable.only(ServicesConfigBlock.builder().build())).withUserAgent(userAgent);
    AtlasDbDialogueServiceProvider dialogueServiceProvider = AtlasDbDialogueServiceProvider.create(serverListConfig, reloadingFactory, userAgent, taggedMetrics);
    return dialogueServiceProvider.getTimeLockManagementService();
}
Also used : AtlasDbDialogueServiceProvider(com.palantir.atlasdb.factory.AtlasDbDialogueServiceProvider) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) DialogueClients(com.palantir.dialogue.clients.DialogueClients)

Example 2 with UserAgent

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

the class Retrofit2ClientBuilderTest method testUserAgent_augmentedByHttpRemotingAndServiceComponents.

@Test
public void testUserAgent_augmentedByHttpRemotingAndServiceComponents() throws Exception {
    TestService service = Retrofit2Client.create(TestService.class, AGENT, new HostMetricsRegistry(), createTestConfig(String.format("http://%s:%s/api/", server.getHostName().toUpperCase(), server.getPort())));
    server.enqueue(new MockResponse().setBody("\"server\""));
    service.get().execute();
    RecordedRequest request = server.takeRequest();
    String conjureVersion = OkHttpClients.class.getPackage().getImplementationVersion();
    UserAgent expected = AGENT.addAgent(UserAgent.Agent.of("TestService", "0.0.0")).addAgent(UserAgent.Agent.of(UserAgents.CONJURE_AGENT_NAME, conjureVersion != null ? conjureVersion : "0.0.0"));
    assertThat(request.getHeader("User-Agent")).isEqualTo(UserAgents.format(expected));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) OkHttpClients(com.palantir.conjure.java.okhttp.OkHttpClients) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) HostMetricsRegistry(com.palantir.conjure.java.okhttp.HostMetricsRegistry) Test(org.junit.Test)

Example 3 with UserAgent

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

the class OkHttpClients method augmentUserAgent.

/**
 * Adds informational {@link Agent}s to the given {@link UserAgent}, one for the conjure-java-runtime library and
 * one for the given service class. Version strings are extracted from the packages'
 * {@link Package#getImplementationVersion implementation version}, defaulting to 0.0.0 if no version can be found.
 */
private static UserAgent augmentUserAgent(UserAgent agent, Class<?> serviceClass) {
    UserAgent augmentedAgent = agent;
    String maybeServiceVersion = serviceClass.getPackage().getImplementationVersion();
    augmentedAgent = augmentedAgent.addAgent(UserAgent.Agent.of(serviceClass.getSimpleName(), maybeServiceVersion != null ? maybeServiceVersion : "0.0.0"));
    String maybeRemotingVersion = OkHttpClients.class.getPackage().getImplementationVersion();
    augmentedAgent = augmentedAgent.addAgent(UserAgent.Agent.of(UserAgents.CONJURE_AGENT_NAME, maybeRemotingVersion != null ? maybeRemotingVersion : "0.0.0"));
    return augmentedAgent;
}
Also used : UserAgent(com.palantir.conjure.java.api.config.service.UserAgent)

Example 4 with UserAgent

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

the class AtlasDbDialogueServiceProvider method create.

public static AtlasDbDialogueServiceProvider create(Refreshable<ServerListConfig> timeLockServerListConfig, DialogueClients.ReloadingFactory baseFactory, UserAgent userAgent, TaggedMetricRegistry taggedMetricRegistry) {
    UserAgent versionedAgent = userAgent.addAgent(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT_AGENT);
    Refreshable<Map<String, RemoteServiceConfiguration>> timeLockRemoteConfigurations = timeLockServerListConfig.map(serverListConfig -> getServiceConfigurations(versionedAgent, serverListConfig));
    DialogueClients.ReloadingFactory reloadingFactory = decorateForFailoverServices(baseFactory, timeLockRemoteConfigurations).withUserAgent(versionedAgent);
    return new AtlasDbDialogueServiceProvider(reloadingFactory, taggedMetricRegistry, timeLockServerListConfig);
}
Also used : UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) ReloadingFactory(com.palantir.dialogue.clients.DialogueClients.ReloadingFactory) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) DialogueClients(com.palantir.dialogue.clients.DialogueClients)

Example 5 with UserAgent

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

the class BroadcastDialogueClientFactory method create.

public static BroadcastDialogueClientFactory create(DialogueClients.ReloadingFactory baseFactory, Refreshable<ServerListConfig> serverListConfigSupplier, UserAgent userAgent, AuxiliaryRemotingParameters parameters) {
    UserAgent versionedAgent = userAgent.addAgent(AtlasDbRemotingConstants.ATLASDB_HTTP_CLIENT_AGENT);
    Refreshable<Map<String, RemoteServiceConfiguration>> timeLockRemoteConfigurations = serverListConfigSupplier.map(serverListConfig -> createRemoteServiceConfigurations(serverListConfig, versionedAgent, parameters));
    DialogueClients.ReloadingFactory reloadingFactory = baseFactory.reloading(timeLockRemoteConfigurations.map(DialogueClientOptions::toServicesConfigBlock)).withUserAgent(versionedAgent);
    return new BroadcastDialogueClientFactory(reloadingFactory, serverListConfigSupplier);
}
Also used : DialogueClientOptions(com.palantir.atlasdb.http.v2.DialogueClientOptions) UserAgent(com.palantir.conjure.java.api.config.service.UserAgent) Map(java.util.Map) DialogueClients(com.palantir.dialogue.clients.DialogueClients)

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