change name of waitForSuspendedRequestsOnShutdown to asyncGraceful
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
0fae221afa
commit
c0268c590f
|
@ -6,8 +6,8 @@
|
|||
<Call name="insertHandler">
|
||||
<Arg>
|
||||
<New id="StatsHandler" class="org.eclipse.jetty.server.handler.StatisticsHandler">
|
||||
<Set name="waitForSuspendedRequestsOnShutdown">
|
||||
<Property name="jetty.statistics.waitForSuspendedRequestsOnShutdown" default="true"/>
|
||||
<Set name="asyncGraceful">
|
||||
<Property name="jetty.statistics.asyncGraceful" default="true"/>
|
||||
</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -431,7 +431,7 @@ public class StatisticsHandlerTest
|
|||
CyclicBarrier barrier = new CyclicBarrier(3);
|
||||
final AtomicReference<AsyncContext> 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<AsyncContext> asyncHolder = new AtomicReference<>();
|
||||
final CountDownLatch dispatched = new CountDownLatch(1);
|
||||
_statsHandler.waitForSuspendedRequestsOnShutdown(false);
|
||||
_statsHandler.setAsyncGraceful(false);
|
||||
_statsHandler.setHandler(new AbstractHandler()
|
||||
{
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue