From c0268c590f118720537e1b72c9a4cb1915cdfc39 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Mon, 24 Aug 2020 16:17:51 +1000 Subject: [PATCH] change name of waitForSuspendedRequestsOnShutdown to asyncGraceful Signed-off-by: Lachlan Roberts --- .../src/main/config/etc/jetty-stats.xml | 4 ++-- jetty-server/src/main/config/modules/stats.mod | 4 ++-- .../jetty/server/handler/StatisticsHandler.java | 17 +++++++++-------- .../eclipse/jetty/server/GracefulStopTest.java | 1 + .../server/handler/StatisticsHandlerTest.java | 4 ++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/jetty-server/src/main/config/etc/jetty-stats.xml b/jetty-server/src/main/config/etc/jetty-stats.xml index 9423fad2abd..9a514ab7ef5 100644 --- a/jetty-server/src/main/config/etc/jetty-stats.xml +++ b/jetty-server/src/main/config/etc/jetty-stats.xml @@ -6,8 +6,8 @@ - - + + diff --git a/jetty-server/src/main/config/modules/stats.mod b/jetty-server/src/main/config/modules/stats.mod index be551a058d0..23b0f16237a 100644 --- a/jetty-server/src/main/config/modules/stats.mod +++ b/jetty-server/src/main/config/modules/stats.mod @@ -18,5 +18,5 @@ jetty.webapp.addServerClasses+=,-org.eclipse.jetty.servlet.StatisticsServlet [ini-template] -## If the Graceful shutdown should wait for suspended requests as well as dispatched ones. -# jetty.statistics.waitForSuspendedRequestsOnShutdown=true +## If the Graceful shutdown should wait for async requests as well as the currently dispatched ones. +# jetty.statistics.asyncGraceful=true diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java index 059541fa17a..9a45a0874e4 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/StatisticsHandler.java @@ -66,7 +66,7 @@ public class StatisticsHandler extends HandlerWrapper implements Graceful private final LongAdder _responses5xx = new LongAdder(); private final LongAdder _responsesTotalBytes = new LongAdder(); - private boolean waitForSuspendedRequestsOnShutdown = true; + private boolean asyncGraceful = true; private final Graceful.Shutdown _shutdown = new Graceful.Shutdown() { @@ -113,7 +113,7 @@ public class StatisticsHandler extends HandlerWrapper implements Graceful _asyncWaitStats.decrement(); // If we have no more dispatches, should we signal shutdown? - if (numRequests == 0 && waitForSuspendedRequestsOnShutdown) + if (numRequests == 0 && asyncGraceful) { FutureCallback shutdown = _shutdown.get(); if (shutdown != null) @@ -204,7 +204,7 @@ public class StatisticsHandler extends HandlerWrapper implements Graceful response.flushBuffer(); // If we either have no more requests or dispatches, we can complete shutdown. - if (waitForSuspendedRequestsOnShutdown ? (numRequests == 0) : (numDispatches == 0)) + if (asyncGraceful ? (numRequests == 0) : (numDispatches == 0)) shutdown.succeeded(); } } @@ -260,13 +260,14 @@ public class StatisticsHandler extends HandlerWrapper implements Graceful } /** - * Set whether the graceful shutdown should wait for all requests to complete (including suspended requests) - * or whether it should only wait for all the actively dispatched requests to complete. - * @param waitForSuspendedRequests true to wait for suspended requests on graceful shutdown. + * Set whether the graceful shutdown should wait for all requests to complete including + * async requests which are not currently dispatched, or whether it should only wait for all the + * actively dispatched requests to complete. + * @param asyncGraceful true to wait for async requests on graceful shutdown. */ - public void waitForSuspendedRequestsOnShutdown(boolean waitForSuspendedRequests) + public void setAsyncGraceful(boolean asyncGraceful) { - this.waitForSuspendedRequestsOnShutdown = waitForSuspendedRequests; + this.asyncGraceful = asyncGraceful; } /** diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/GracefulStopTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/GracefulStopTest.java index 10fd5d12cbc..1627cff6f9d 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/GracefulStopTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/GracefulStopTest.java @@ -558,6 +558,7 @@ public class GracefulStopTest public void testCommittedResponsesAreClosed() throws Exception { Server server = new Server(); + server.setDumpAfterStart(true); LocalConnector connector = new LocalConnector(server); server.addConnector(connector); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/StatisticsHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/StatisticsHandlerTest.java index ed7aed02be7..c4bbc702cf9 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/StatisticsHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/StatisticsHandlerTest.java @@ -431,7 +431,7 @@ public class StatisticsHandlerTest CyclicBarrier barrier = new CyclicBarrier(3); final AtomicReference asyncHolder = new AtomicReference<>(); final CountDownLatch dispatched = new CountDownLatch(1); - _statsHandler.waitForSuspendedRequestsOnShutdown(true); + _statsHandler.setAsyncGraceful(true); _statsHandler.setHandler(new AbstractHandler() { @Override @@ -487,7 +487,7 @@ public class StatisticsHandlerTest CyclicBarrier barrier = new CyclicBarrier(3); final AtomicReference asyncHolder = new AtomicReference<>(); final CountDownLatch dispatched = new CountDownLatch(1); - _statsHandler.waitForSuspendedRequestsOnShutdown(false); + _statsHandler.setAsyncGraceful(false); _statsHandler.setHandler(new AbstractHandler() { @Override