Search in sources :

Example 1 with Clients

use of com.palantir.dialogue.Clients in project dialogue by palantir.

the class Benchmark method addEndpointChannel.

public BenchmarkTimingEndpointChannel addEndpointChannel(String client, Endpoint endpoint, Channel channel) {
    Preconditions.checkArgument(endpoint.serviceName().equals(SimulationUtils.SERVICE_NAME), "Must have a consistent service name for our graphs to work", SafeArg.of("endpoint", endpoint));
    Clients utils = DefaultConjureRuntime.builder().build().clients();
    EndpointChannel endpointChannel = utils.bind(channel, endpoint);
    BenchmarkTimingEndpointChannel toReturn = new BenchmarkTimingEndpointChannel(simulation, client, endpoint, endpointChannel);
    endpointChannels.add(ImmutableNamedEndpointChannel.builder().name(String.format("%s %s", client, endpoint.endpointName())).channel(toReturn).build());
    return toReturn;
}
Also used : EndpointChannel(com.palantir.dialogue.EndpointChannel) Clients(com.palantir.dialogue.Clients)

Example 2 with Clients

use of com.palantir.dialogue.Clients in project dialogue by palantir.

the class Benchmark method endpoints.

public Benchmark endpoints(Endpoint... endpoints) {
    Preconditions.checkNotNull(clients, "Must call client or clients first");
    Preconditions.checkNotNull(requestStream, "Must call sendUntil or numRequests first");
    Preconditions.checkNotNull(simulation, "Must call .simulation() first");
    endpointChannels = new ArrayList<>();
    Arrays.stream(clients).forEach(client -> Arrays.stream(endpoints).forEach(endpoint -> addEndpointChannel(client.name(), endpoint, client.channel())));
    Random pseudoRandom = new Random(21876781263L);
    int count = endpointChannels.size();
    endpointChannelChooser = () -> pseudoRandom.nextInt(count);
    return this;
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Stopwatch(com.google.common.base.Stopwatch) LoggerFactory(org.slf4j.LoggerFactory) Random(java.util.Random) SettableFuture(com.google.common.util.concurrent.SettableFuture) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) DialogueFutures(com.palantir.dialogue.futures.DialogueFutures) SafeArg(com.palantir.logsafe.SafeArg) Value(org.immutables.value.Value) Duration(java.time.Duration) Map(java.util.Map) DefaultConjureRuntime(com.palantir.conjure.java.dialogue.serde.DefaultConjureRuntime) Endpoint(com.palantir.dialogue.Endpoint) Request(com.palantir.dialogue.Request) IntSupplier(java.util.function.IntSupplier) IntFunction(java.util.function.IntFunction) LongStream(java.util.stream.LongStream) Logger(org.slf4j.Logger) KeyedStream(com.palantir.common.streams.KeyedStream) Clients(com.palantir.dialogue.Clients) Streams(com.google.common.collect.Streams) Channel(com.palantir.dialogue.Channel) HttpMethod(com.palantir.dialogue.HttpMethod) Collectors(java.util.stream.Collectors) Snapshot(com.codahale.metrics.Snapshot) FutureCallback(com.google.common.util.concurrent.FutureCallback) TimeUnit(java.util.concurrent.TimeUnit) Futures(com.google.common.util.concurrent.Futures) EndpointChannel(com.palantir.dialogue.EndpointChannel) List(java.util.List) Stream(java.util.stream.Stream) TreeMap(java.util.TreeMap) Optional(java.util.Optional) BaseStream(java.util.stream.BaseStream) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Comparator(java.util.Comparator) Response(com.palantir.dialogue.Response) Preconditions(com.palantir.logsafe.Preconditions) Random(java.util.Random) Endpoint(com.palantir.dialogue.Endpoint)

Example 3 with Clients

use of com.palantir.dialogue.Clients in project dialogue by palantir.

the class EndToEndBenchmark method before.

@Setup
public void before() {
    undertow = Undertow.builder().addHttpListener(0, "localhost", new ResponseCodeHandler(200)).build();
    undertow.start();
    TaggedMetricRegistry metrics = new DefaultTaggedMetricRegistry();
    blockingExecutor = Tracers.wrap("dialogue-blocking-channel", Executors.newCachedThreadPool(MetricRegistries.instrument(metrics, new ThreadFactoryBuilder().setNameFormat("dialogue-blocking-channel-%d").setDaemon(true).build(), "dialogue-blocking-channel")));
    DialogueClients.ReloadingFactory clients = DialogueClients.create(Refreshable.only(null)).withUserAgent(TestConfigurations.AGENT).withTaggedMetrics(metrics).withBlockingExecutor(blockingExecutor);
    ServiceConfiguration serviceConf = ServiceConfiguration.builder().addUris(getUri(undertow)).security(TestConfigurations.SSL_CONFIG).build();
    blocking = clients.getNonReloading(SampleServiceBlocking.class, serviceConf);
    ClientConfiguration clientConf = ClientConfiguration.builder().from(ClientConfigurations.of(serviceConf)).taggedMetricRegistry(metrics).userAgent(TestConfigurations.AGENT).build();
    closeableApache = ApacheHttpClientChannels.clientBuilder().executor(blockingExecutor).clientConfiguration(clientConf).clientName("clientName").build();
    apacheChannel = ApacheHttpClientChannels.createSingleUri(serviceConf.uris().get(0), closeableApache);
    Channel zeroNetworkChannel = DialogueChannel.builder().channelName("goFast").clientConfiguration(clientConf).factory(_uri -> InstantChannel.INSTANCE).buildNonLiveReloading();
    zeroNetworkDialogue = SampleServiceBlocking.of(zeroNetworkChannel, DefaultConjureRuntime.builder().build());
}
Also used : ResponseCodeHandler(io.undertow.server.handlers.ResponseCodeHandler) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) Iterables(com.google.common.collect.Iterables) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Measurement(org.openjdk.jmh.annotations.Measurement) Scope(org.openjdk.jmh.annotations.Scope) ClientConfiguration(com.palantir.conjure.java.client.config.ClientConfiguration) TestEndpoint(com.palantir.dialogue.TestEndpoint) Warmup(org.openjdk.jmh.annotations.Warmup) SampleServiceBlocking(com.palantir.dialogue.example.SampleServiceBlocking) Undertow(io.undertow.Undertow) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit) Tracers(com.palantir.tracing.Tracers) DefaultConjureRuntime(com.palantir.conjure.java.dialogue.serde.DefaultConjureRuntime) Endpoint(com.palantir.dialogue.Endpoint) ApacheHttpClientChannels(com.palantir.dialogue.hc5.ApacheHttpClientChannels) TearDown(org.openjdk.jmh.annotations.TearDown) ServiceConfiguration(com.palantir.conjure.java.api.config.service.ServiceConfiguration) Request(com.palantir.dialogue.Request) Threads(org.openjdk.jmh.annotations.Threads) Runner(org.openjdk.jmh.runner.Runner) ClientConfigurations(com.palantir.conjure.java.client.config.ClientConfigurations) ExecutorService(java.util.concurrent.ExecutorService) Refreshable(com.palantir.refreshable.Refreshable) Setup(org.openjdk.jmh.annotations.Setup) Mode(org.openjdk.jmh.annotations.Mode) IOException(java.io.IOException) Clients(com.palantir.dialogue.Clients) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) Channel(com.palantir.dialogue.Channel) MetricRegistries(com.palantir.tritium.metrics.MetricRegistries) State(org.openjdk.jmh.annotations.State) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) TestConfigurations(com.palantir.dialogue.TestConfigurations) Executors(java.util.concurrent.Executors) Benchmark(org.openjdk.jmh.annotations.Benchmark) TimeUnit(java.util.concurrent.TimeUnit) TestResponse(com.palantir.dialogue.TestResponse) OptionsBuilder(org.openjdk.jmh.runner.options.OptionsBuilder) Futures(com.google.common.util.concurrent.Futures) ResponseCodeHandler(io.undertow.server.handlers.ResponseCodeHandler) Fork(org.openjdk.jmh.annotations.Fork) DialogueClients(com.palantir.dialogue.clients.DialogueClients) Response(com.palantir.dialogue.Response) Options(org.openjdk.jmh.runner.options.Options) ServiceConfiguration(com.palantir.conjure.java.api.config.service.ServiceConfiguration) Channel(com.palantir.dialogue.Channel) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) DialogueClients(com.palantir.dialogue.clients.DialogueClients) ClientConfiguration(com.palantir.conjure.java.client.config.ClientConfiguration) SampleServiceBlocking(com.palantir.dialogue.example.SampleServiceBlocking) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

Clients (com.palantir.dialogue.Clients)3 Futures (com.google.common.util.concurrent.Futures)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 DefaultConjureRuntime (com.palantir.conjure.java.dialogue.serde.DefaultConjureRuntime)2 Channel (com.palantir.dialogue.Channel)2 Endpoint (com.palantir.dialogue.Endpoint)2 EndpointChannel (com.palantir.dialogue.EndpointChannel)2 Request (com.palantir.dialogue.Request)2 Response (com.palantir.dialogue.Response)2 TimeUnit (java.util.concurrent.TimeUnit)2 Snapshot (com.codahale.metrics.Snapshot)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Stopwatch (com.google.common.base.Stopwatch)1 Iterables (com.google.common.collect.Iterables)1 Iterators (com.google.common.collect.Iterators)1 Streams (com.google.common.collect.Streams)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 SettableFuture (com.google.common.util.concurrent.SettableFuture)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1