summaryrefslogtreecommitdiffstats
path: root/vespa-feed-client
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@gmail.com>2023-09-11 22:37:01 +0200
committerGitHub <noreply@github.com>2023-09-11 22:37:01 +0200
commit22604cd1b461d790a3c437de5cccd9d485af374c (patch)
tree2832f8b896fe2f381f940260708aac66bf2cf01a /vespa-feed-client
parent9c6acb304589c79823f75dd96b4ac09bcb91407f (diff)
Revert "Bjorncs/improve feed client"
Diffstat (limited to 'vespa-feed-client')
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/HttpRequestStrategy.java10
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java9
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/StaticThrottler.java6
3 files changed, 9 insertions, 16 deletions
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/HttpRequestStrategy.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/HttpRequestStrategy.java
index fba9ef06f2b..ebbff9ed84b 100644
--- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/HttpRequestStrategy.java
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/HttpRequestStrategy.java
@@ -6,12 +6,14 @@ import ai.vespa.feed.client.FeedClient;
import ai.vespa.feed.client.FeedClient.CircuitBreaker;
import ai.vespa.feed.client.FeedClient.RetryStrategy;
import ai.vespa.feed.client.FeedException;
-import ai.vespa.feed.client.HttpResponse;
+import ai.vespa.feed.client.HttpResponse ;
import ai.vespa.feed.client.OperationStats;
import java.io.IOException;
+import java.nio.channels.CancelledKeyException;
import java.util.Map;
import java.util.Queue;
+import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -137,10 +139,8 @@ class HttpRequestStrategy implements RequestStrategy {
private boolean retry(HttpRequest request, Throwable thrown, int attempt) {
breaker.failure(thrown);
if ( (thrown instanceof IOException) // General IO problems.
-
- // Thrown by HTTP2Session.StreamsState.reserveSlot, likely on GOAWAY from server
- || (thrown instanceof IllegalStateException && thrown.getMessage().equals("session closed"))
- ) {
+ || (thrown instanceof CancellationException) // TLS session disconnect.
+ || (thrown instanceof CancelledKeyException)) { // Selection cancelled.
log.log(FINER, thrown, () -> "Failed attempt " + attempt + " at " + request);
return retry(request, attempt);
}
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java
index e4e6fbe752e..819115fd867 100644
--- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/JettyCluster.java
@@ -26,7 +26,6 @@ import org.eclipse.jetty.http2.client.http.ClientConnectionFactoryOverHTTP2;
import org.eclipse.jetty.io.ClientConnectionFactory;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.util.HttpCookieStore;
-import org.eclipse.jetty.util.Jetty;
import org.eclipse.jetty.util.Pool;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.SocketAddressResolver;
@@ -140,9 +139,7 @@ class JettyCluster implements Cluster {
connector.setExecutor(new QueuedThreadPool(threads));
connector.setSslContextFactory(clientSslCtxFactory);
connector.setIdleTimeout(IDLE_TIMEOUT);
- boolean secureProxy = b.proxy != null && b.proxy.getScheme().equals("https");
- // Increase connect timeout for secure HTTP/2 proxy
- connector.setConnectTimeout(Duration.ofSeconds(secureProxy ? 120 : 30));
+ connector.setConnectTimeout(Duration.ofSeconds(10));
HTTP2Client h2Client = new HTTP2Client(connector);
h2Client.setMaxConcurrentPushedStreams(b.maxStreamsPerConnection);
// Set the HTTP/2 flow control windows very large to cause TCP congestion instead of HTTP/2 flow control congestion.
@@ -158,15 +155,13 @@ class JettyCluster implements Cluster {
MultiplexConnectionPool pool = new MultiplexConnectionPool(
dest, Pool.StrategyType.RANDOM, connectionsPerEndpoint, false, dest, Integer.MAX_VALUE);
pool.preCreateConnections(connectionsPerEndpoint);
- if (secureProxy) pool.setMaxDuration(Duration.ofMinutes(1).toMillis());
- else pool.setMaximizeConnections(true);
return pool;
});
HttpClient httpClient = new HttpClient(transport);
httpClient.setMaxRequestsQueuedPerDestination(Integer.MAX_VALUE);
httpClient.setFollowRedirects(false);
httpClient.setUserAgentField(
- new HttpField(HttpHeader.USER_AGENT, String.format("vespa-feed-client/%s (Jetty:%s)", Vespa.VERSION, Jetty.VERSION)));
+ new HttpField(HttpHeader.USER_AGENT, String.format("vespa-feed-client/%s (Jetty)", Vespa.VERSION)));
// Stop client from trying different IP address when TLS handshake fails
httpClient.setSocketAddressResolver(new Ipv4PreferringResolver(httpClient, Duration.ofSeconds(10)));
httpClient.setCookieStore(new HttpCookieStore.Empty());
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/StaticThrottler.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/StaticThrottler.java
index 4190bd1f580..1f9cf8e5155 100644
--- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/StaticThrottler.java
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/StaticThrottler.java
@@ -21,10 +21,8 @@ public class StaticThrottler implements Throttler {
private final AtomicLong targetX10;
public StaticThrottler(FeedClientBuilderImpl builder) {
- minInflight = 4L * builder.connectionsPerEndpoint * builder.endpoints.size();
- // Add 1 to buffer some extra requests
- maxInflight = Math.min(builder.maxStreamsPerConnection + 1L, 512)
- * (builder.connectionsPerEndpoint + 1L) * (long)builder.endpoints.size();
+ minInflight = 16L * builder.connectionsPerEndpoint * builder.endpoints.size();
+ maxInflight = 256 * minInflight; // 4096 max streams per connection on the server side.
targetX10 = new AtomicLong(10 * maxInflight); // 10x the actual value to allow for smaller updates.
}