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">
|
<Call name="insertHandler">
|
||||||
<Arg>
|
<Arg>
|
||||||
<New id="StatsHandler" class="org.eclipse.jetty.server.handler.StatisticsHandler">
|
<New id="StatsHandler" class="org.eclipse.jetty.server.handler.StatisticsHandler">
|
||||||
<Set name="waitForSuspendedRequestsOnShutdown">
|
<Set name="asyncGraceful">
|
||||||
<Property name="jetty.statistics.waitForSuspendedRequestsOnShutdown" default="true"/>
|
<Property name="jetty.statistics.asyncGraceful" default="true"/>
|
||||||
</Set>
|
</Set>
|
||||||
</New>
|
</New>
|
||||||
</Arg>
|
</Arg>
|
||||||
|
|
|
@ -18,5 +18,5 @@ jetty.webapp.addServerClasses+=,-org.eclipse.jetty.servlet.StatisticsServlet
|
||||||
|
|
||||||
[ini-template]
|
[ini-template]
|
||||||
|
|
||||||
## If the Graceful shutdown should wait for suspended requests as well as dispatched ones.
|
## If the Graceful shutdown should wait for async requests as well as the currently dispatched ones.
|
||||||
# jetty.statistics.waitForSuspendedRequestsOnShutdown=true
|
# jetty.statistics.asyncGraceful=true
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class StatisticsHandler extends HandlerWrapper implements Graceful
|
||||||
private final LongAdder _responses5xx = new LongAdder();
|
private final LongAdder _responses5xx = new LongAdder();
|
||||||
private final LongAdder _responsesTotalBytes = new LongAdder();
|
private final LongAdder _responsesTotalBytes = new LongAdder();
|
||||||
|
|
||||||
private boolean waitForSuspendedRequestsOnShutdown = true;
|
private boolean asyncGraceful = true;
|
||||||
|
|
||||||
private final Graceful.Shutdown _shutdown = new Graceful.Shutdown()
|
private final Graceful.Shutdown _shutdown = new Graceful.Shutdown()
|
||||||
{
|
{
|
||||||
|
@ -113,7 +113,7 @@ public class StatisticsHandler extends HandlerWrapper implements Graceful
|
||||||
_asyncWaitStats.decrement();
|
_asyncWaitStats.decrement();
|
||||||
|
|
||||||
// If we have no more dispatches, should we signal shutdown?
|
// If we have no more dispatches, should we signal shutdown?
|
||||||
if (numRequests == 0 && waitForSuspendedRequestsOnShutdown)
|
if (numRequests == 0 && asyncGraceful)
|
||||||
{
|
{
|
||||||
FutureCallback shutdown = _shutdown.get();
|
FutureCallback shutdown = _shutdown.get();
|
||||||
if (shutdown != null)
|
if (shutdown != null)
|
||||||
|
@ -204,7 +204,7 @@ public class StatisticsHandler extends HandlerWrapper implements Graceful
|
||||||
response.flushBuffer();
|
response.flushBuffer();
|
||||||
|
|
||||||
// If we either have no more requests or dispatches, we can complete shutdown.
|
// 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();
|
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)
|
* Set whether the graceful shutdown should wait for all requests to complete including
|
||||||
* or whether it should only wait for all the actively dispatched requests to complete.
|
* async requests which are not currently dispatched, or whether it should only wait for all the
|
||||||
* @param waitForSuspendedRequests true to wait for suspended requests on graceful shutdown.
|
* 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
|
public void testCommittedResponsesAreClosed() throws Exception
|
||||||
{
|
{
|
||||||
Server server = new Server();
|
Server server = new Server();
|
||||||
|
server.setDumpAfterStart(true);
|
||||||
|
|
||||||
LocalConnector connector = new LocalConnector(server);
|
LocalConnector connector = new LocalConnector(server);
|
||||||
server.addConnector(connector);
|
server.addConnector(connector);
|
||||||
|
|
|
@ -431,7 +431,7 @@ public class StatisticsHandlerTest
|
||||||
CyclicBarrier barrier = new CyclicBarrier(3);
|
CyclicBarrier barrier = new CyclicBarrier(3);
|
||||||
final AtomicReference<AsyncContext> asyncHolder = new AtomicReference<>();
|
final AtomicReference<AsyncContext> asyncHolder = new AtomicReference<>();
|
||||||
final CountDownLatch dispatched = new CountDownLatch(1);
|
final CountDownLatch dispatched = new CountDownLatch(1);
|
||||||
_statsHandler.waitForSuspendedRequestsOnShutdown(true);
|
_statsHandler.setAsyncGraceful(true);
|
||||||
_statsHandler.setHandler(new AbstractHandler()
|
_statsHandler.setHandler(new AbstractHandler()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -487,7 +487,7 @@ public class StatisticsHandlerTest
|
||||||
CyclicBarrier barrier = new CyclicBarrier(3);
|
CyclicBarrier barrier = new CyclicBarrier(3);
|
||||||
final AtomicReference<AsyncContext> asyncHolder = new AtomicReference<>();
|
final AtomicReference<AsyncContext> asyncHolder = new AtomicReference<>();
|
||||||
final CountDownLatch dispatched = new CountDownLatch(1);
|
final CountDownLatch dispatched = new CountDownLatch(1);
|
||||||
_statsHandler.waitForSuspendedRequestsOnShutdown(false);
|
_statsHandler.setAsyncGraceful(false);
|
||||||
_statsHandler.setHandler(new AbstractHandler()
|
_statsHandler.setHandler(new AbstractHandler()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue