summaryrefslogtreecommitdiffstats
path: root/vespa-feed-client
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2021-06-14 13:11:01 +0200
committerJon Marius Venstad <venstad@gmail.com>2021-06-15 12:41:04 +0200
commitac66e1dc39e30938a91b26eda3d9b715dd3925a5 (patch)
treeabb5bca00855cde33ca5c4ef4a9f2333ee5e3032 /vespa-feed-client
parent7d5a34c4fb5d9a1a4c85a82bbab47be9dc2c8125 (diff)
Make it configurable wheethere to benchmark client
Diffstat (limited to 'vespa-feed-client')
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/FeedClientBuilder.java7
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java4
2 files changed, 9 insertions, 2 deletions
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/FeedClientBuilder.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/FeedClientBuilder.java
index e0418836c80..8b5eb9efea7 100644
--- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/FeedClientBuilder.java
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/FeedClientBuilder.java
@@ -44,6 +44,7 @@ public class FeedClientBuilder {
Collection<X509Certificate> certificate;
PrivateKey privateKey;
Collection<X509Certificate> caCertificates;
+ boolean benchmark;
/** Creates a builder for a single container endpoint **/
public static FeedClientBuilder create(URI endpoint) { return new FeedClientBuilder(Collections.singletonList(endpoint)); }
@@ -100,6 +101,12 @@ public class FeedClientBuilder {
return this;
}
+ /** Turns on/off benchmarking, aggregated in {@link FeedClient#stats()}. */
+ public FeedClientBuilder setBenchmarkOn(boolean on) {
+ this.benchmark = on;
+ return this;
+ }
+
/** Adds HTTP request header to all client requests. */
public FeedClientBuilder addRequestHeader(String name, String value) {
return addRequestHeader(name, () -> requireNonNull(value));
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java
index 3cce423735f..6b2aec5d8b3 100644
--- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpRequestStrategy.java
@@ -59,11 +59,11 @@ class HttpRequestStrategy implements RequestStrategy {
});
HttpRequestStrategy(FeedClientBuilder builder) throws IOException {
- this(builder, new BenchmarkingCluster(new ApacheCluster(builder)));
+ this(builder, new ApacheCluster(builder));
}
HttpRequestStrategy(FeedClientBuilder builder, Cluster cluster) {
- this.cluster = cluster;
+ this.cluster = builder.benchmark ? new BenchmarkingCluster(cluster) : cluster;
this.strategy = builder.retryStrategy;
this.breaker = builder.circuitBreaker;
this.maxInflight = builder.connectionsPerEndpoint * (long) builder.maxStreamsPerConnection;