diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2023-01-09 15:05:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 15:05:47 +0100 |
commit | baf54beef9119768f99d41d950373f742a42df62 (patch) | |
tree | d49cf940d500a6dc1cb0e10af2f6a0810050f51f | |
parent | caca1ab7e615fa628ddb864e72c022e5b22c1951 (diff) | |
parent | c0134657004cff6070defbc668848cb7c1d47f4d (diff) |
Merge pull request #25451 from vespa-engine/jonmv/update--cli-args
Update CLI arguments help.tzt for feed client
7 files changed, 15 insertions, 8 deletions
diff --git a/vespa-feed-client-api/abi-spec.json b/vespa-feed-client-api/abi-spec.json index 64b049dc75d..469928d819c 100644 --- a/vespa-feed-client-api/abi-spec.json +++ b/vespa-feed-client-api/abi-spec.json @@ -125,6 +125,7 @@ "public static ai.vespa.feed.client.FeedClientBuilder$Compression valueOf(java.lang.String)" ], "fields" : [ + "public static final enum ai.vespa.feed.client.FeedClientBuilder$Compression auto", "public static final enum ai.vespa.feed.client.FeedClientBuilder$Compression none", "public static final enum ai.vespa.feed.client.FeedClientBuilder$Compression gzip" ] diff --git a/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedClientBuilder.java b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedClientBuilder.java index d48c3c31348..1217ad205c3 100644 --- a/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedClientBuilder.java +++ b/vespa-feed-client-api/src/main/java/ai/vespa/feed/client/FeedClientBuilder.java @@ -126,7 +126,7 @@ public interface FeedClientBuilder { /** What compression to use for request bodies; default {@code NONE}. */ FeedClientBuilder setCompression(Compression compression); - enum Compression { none, gzip } + enum Compression { auto, none, gzip } /** Constructs instance of {@link FeedClient} from builder configuration */ FeedClient build(); diff --git a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java index d16822aa46e..be6f3263ffc 100644 --- a/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java +++ b/vespa-feed-client-cli/src/main/java/ai/vespa/feed/client/impl/CliArguments.java @@ -370,7 +370,8 @@ class CliArguments { .build()) .addOption(Option.builder() .longOpt(COMPRESSION) - .desc("Compression mode for feed requests: 'none' (default), 'gzip'") + .desc("Forced compression mode for feed requests; the default is to compress large requests. " + + "Valid arguments are: 'auto' (default), 'none', 'gzip'") .hasArg() .type(Compression.class) .build()); diff --git a/vespa-feed-client-cli/src/test/resources/help.txt b/vespa-feed-client-cli/src/test/resources/help.txt index f33dde82f7b..554c42af3dc 100644 --- a/vespa-feed-client-cli/src/test/resources/help.txt +++ b/vespa-feed-client-cli/src/test/resources/help.txt @@ -6,9 +6,11 @@ Vespa feed client certificates encoded as PEM --certificate <arg> Path to PEM encoded X.509 certificate file - --compression <arg> Compression mode for feed - requests: 'none' (default), - 'gzip' + --compression <arg> Forced compression mode for feed + requests; the default is to + compress large requests. Valid + arguments are: 'auto' (default), + 'none', 'gzip' --connections <arg> Number of concurrent HTTP/2 connections --disable-ssl-hostname-verification Disable SSL hostname diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/ApacheCluster.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/ApacheCluster.java index 639aebf7c46..19f3ccf7a83 100644 --- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/ApacheCluster.java +++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/ApacheCluster.java @@ -36,6 +36,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.zip.GZIPOutputStream; +import static ai.vespa.feed.client.FeedClientBuilder.Compression.auto; +import static ai.vespa.feed.client.FeedClientBuilder.Compression.gzip; import static org.apache.hc.core5.http.ssl.TlsCiphers.excludeH2Blacklisted; import static org.apache.hc.core5.http.ssl.TlsCiphers.excludeWeak; @@ -89,7 +91,7 @@ class ApacheCluster implements Cluster { wrapped.headers().forEach((name, value) -> request.setHeader(name, value.get())); if (wrapped.body() != null) { byte[] body = wrapped.body(); - if (compression == Compression.gzip || compression == null && body.length > 512) { + if (compression == gzip || compression == auto && body.length > 512) { request.setHeader(gzipEncodingHeader); body = gzipped(body); } diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/FeedClientBuilderImpl.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/FeedClientBuilderImpl.java index b364ba953eb..e5bfffbf24d 100644 --- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/FeedClientBuilderImpl.java +++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/FeedClientBuilderImpl.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Map; import java.util.function.Supplier; +import static ai.vespa.feed.client.FeedClientBuilder.Compression.auto; import static ai.vespa.feed.client.FeedClientBuilder.Compression.none; import static java.util.Objects.requireNonNull; @@ -51,7 +52,7 @@ public class FeedClientBuilderImpl implements FeedClientBuilder { boolean benchmark = true; boolean dryrun = false; boolean speedTest = false; - Compression compression = null; + Compression compression = auto; URI proxy; diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/ApacheClusterTest.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/ApacheClusterTest.java index 33c043ea271..0c7d94c04ec 100644 --- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/ApacheClusterTest.java +++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/ApacheClusterTest.java @@ -62,7 +62,7 @@ class ApacheClusterTest { .withHeader("Content-Type", equalTo("application/json; charset=UTF-8")) .withRequestBody(equalTo("content")); expected = switch (compression) { - case none -> expected.withoutHeader("Content-Encoding"); + case auto, none -> expected.withoutHeader("Content-Encoding"); case gzip -> expected.withHeader("Content-Encoding", equalTo("gzip")); }; server.verify(1, expected); |