From e7a07074f52666fd064f478ccebf3456c9ee3372 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 13 Aug 2020 08:42:44 -0500 Subject: [PATCH 1/2] Setting DemoBaseTest.testAsyncRest() as @Tag("external") Signed-off-by: Joakim Erdfelt --- .../org/eclipse/jetty/tests/distribution/DemoBaseTests.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java index 631b9912d83..7c01b5cf713 100644 --- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java +++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java @@ -26,6 +26,7 @@ import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.util.FormContentProvider; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.util.Fields; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnJre; import org.junit.jupiter.api.condition.JRE; @@ -72,6 +73,7 @@ public class DemoBaseTests extends AbstractDistributionTest } @Test + @Tag("external") public void testAsyncRest() throws Exception { String jettyVersion = System.getProperty("jettyVersion"); From 26c2d34439a2e048f69ca1fe20150603fa416f3f Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 13 Aug 2020 16:52:06 +0200 Subject: [PATCH 2/2] Issue #4809 - Set a max number of requests per connection. Improved Pool.reserve(int) logic to take into account the fact that an entry can accommodate maxMultiplex acquires. This reduces connection openings for HTTP/2 in case of spikes of requests. Signed-off-by: Simone Bordet --- .../src/main/java/org/eclipse/jetty/util/Pool.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Pool.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Pool.java index 4172e145743..ca16fa38208 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Pool.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Pool.java @@ -140,13 +140,13 @@ public class Pool implements AutoCloseable, Dumpable * method called or be removed via {@link Pool.Entry#remove()} or * {@link Pool#remove(Pool.Entry)}. * - * @param maxReservations the max desired number of reserved entries, + * @param allotment the desired allotment, where each entry handles an allotment of maxMultiplex, * or a negative number to always trigger the reservation of a new entry. * @return a disabled entry that is contained in the pool, * or null if the pool is closed or if the pool already contains - * {@link #getMaxEntries()} entries. + * {@link #getMaxEntries()} entries, or the allotment has already been reserved */ - public Entry reserve(int maxReservations) + public Entry reserve(int allotment) { try (Locker.Lock l = locker.lock()) { @@ -159,9 +159,8 @@ public class Pool implements AutoCloseable, Dumpable // The pending count is an AtomicInteger that is only ever incremented here with // the lock held. Thus the pending count can be reduced immediately after the - // test below, but never incremented. Thus the maxReservations limit can be - // enforced. - if (maxReservations >= 0 && pending.get() >= maxReservations) + // test below, but never incremented. Thus the allotment limit can be enforced. + if (allotment >= 0 && (pending.get() * getMaxMultiplex()) >= allotment) return null; pending.incrementAndGet();