diff options
Diffstat (limited to 'vespa-feed-client')
-rw-r--r-- | vespa-feed-client/src/main/java/ai/vespa/feed/client/DynamicThrottler.java | 2 | ||||
-rw-r--r-- | vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpRequestStrategyTest.java | 19 |
2 files changed, 17 insertions, 4 deletions
diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/DynamicThrottler.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/DynamicThrottler.java index 44f5d8b537f..ef4d228466b 100644 --- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/DynamicThrottler.java +++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/DynamicThrottler.java @@ -18,7 +18,7 @@ import static java.lang.Math.random; * * @author jonmv */ -class DynamicThrottler extends StaticThrottler { +public class DynamicThrottler extends StaticThrottler { private final AtomicLong targetInflight; private long updateNanos = 0; diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpRequestStrategyTest.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpRequestStrategyTest.java index fe62db9e0bb..4ef24713e9a 100644 --- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpRequestStrategyTest.java +++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/HttpRequestStrategyTest.java @@ -13,6 +13,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -36,17 +37,29 @@ class HttpRequestStrategyTest { HttpRequest request = new HttpRequest("PUT", "/", null, null); HttpResponse response = HttpResponse.of(200, "{}".getBytes(UTF_8)); ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); - Cluster cluster = new BenchmarkingCluster((__, vessel) -> executor.schedule(() -> vessel.complete(response), 100, TimeUnit.MILLISECONDS)); + Cluster cluster = new BenchmarkingCluster((__, vessel) -> executor.schedule(() -> vessel.complete(response), (int) (Math.random() * 2 * 10), TimeUnit.MILLISECONDS)); HttpRequestStrategy strategy = new HttpRequestStrategy(FeedClientBuilder.create(URI.create("https://dummy.com:123")) - .setConnectionsPerEndpoint(1 << 12) - .setMaxStreamPerConnection(1 << 4), + .setConnectionsPerEndpoint(1 << 4) + .setMaxStreamPerConnection(1 << 20), cluster); + CountDownLatch latch = new CountDownLatch(1); + new Thread(() -> { + try { + while ( ! latch.await(1, TimeUnit.SECONDS)) { + System.err.println(cluster.stats().inflight()); + System.err.println(strategy.throttler.targetInflight()); + System.err.println(); + } + } + catch (InterruptedException ignored) { } + }).start(); long startNanos = System.nanoTime(); for (int i = 0; i < documents; i++) strategy.enqueue(DocumentId.of("ns", "type", Integer.toString(i)), request); strategy.await(); + latch.countDown(); executor.shutdown(); cluster.close(); OperationStats stats = cluster.stats(); |