summaryrefslogtreecommitdiffstats
path: root/vespa-feed-client
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2023-06-05 13:44:53 +0200
committerHarald Musum <musum@yahooinc.com>2023-06-05 13:44:53 +0200
commita7d018760363ae9ca0e4349e0a7e0ed70fb4f52e (patch)
tree5c2cb2b44d09aec419686da3896fcc19614edd48 /vespa-feed-client
parent4864d94e48919a8cb734191ab90b80738e843d08 (diff)
Increase timeout and add some more to exception message when connection fails
Diffstat (limited to 'vespa-feed-client')
-rw-r--r--vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/HttpFeedClient.java7
-rw-r--r--vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java8
2 files changed, 10 insertions, 5 deletions
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/HttpFeedClient.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/HttpFeedClient.java
index 3f54808a758..730d9787735 100644
--- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/HttpFeedClient.java
+++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/impl/HttpFeedClient.java
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.time.Duration;
+import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;
@@ -128,12 +129,13 @@ class HttpFeedClient implements FeedClient {
}
private void verifyConnection(FeedClientBuilderImpl builder, Cluster cluster) {
+ Instant start = Instant.now();
try {
HttpRequest request = new HttpRequest("POST",
getPath(DocumentId.of("feeder", "handshake", "dummy")) + getQuery(empty(), true),
requestHeaders,
null,
- Duration.ofSeconds(10));
+ Duration.ofSeconds(15));
CompletableFuture<HttpResponse> future = new CompletableFuture<>();
cluster.dispatch(request, future);
HttpResponse response = future.get(20, TimeUnit.SECONDS);
@@ -155,7 +157,8 @@ class HttpFeedClient implements FeedClient {
}
}
catch (ExecutionException e) {
- throw new FeedException("failed handshake with server: " + e.getCause(), e.getCause());
+ Duration duration = Duration.between(start, Instant.now());
+ throw new FeedException("failed handshake with server after " + duration + ": " + e.getCause(), e.getCause());
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java
index 295108b5ed5..66c9adb2ced 100644
--- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java
+++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/impl/HttpFeedClientTest.java
@@ -213,9 +213,11 @@ class HttpFeedClientTest {
@Test
void testHandshake() {
// dummy:123 does not exist, and results in a host-not-found exception.
- assertTrue(assertThrows(FeedException.class,
- () -> new HttpFeedClient(new FeedClientBuilderImpl(Collections.singletonList(URI.create("https://dummy:123")))))
- .getMessage().startsWith("failed handshake with server: java.net.UnknownHostException"));
+ FeedException exception = assertThrows(FeedException.class,
+ () -> new HttpFeedClient(new FeedClientBuilderImpl(Collections.singletonList(URI.create("https://dummy:123")))));
+ String message = exception.getMessage();
+ assertTrue(message.startsWith("failed handshake with server after "), message);
+ assertTrue(message.contains("java.net.UnknownHostException"), message);
HttpResponse oldResponse = HttpResponse.of(400, "{\"pathId\":\"/document/v1/test/build/docid/foo\",\"message\":\"Could not read document, no document?\"}".getBytes(UTF_8));
HttpResponse okResponse = HttpResponse.of(200, null);