Remove graceful handling from ManagedSelector stop #2046

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2018-01-11 10:29:27 +01:00
parent 7d9f2d7e64
commit 385ba7d70d
2 changed files with 9 additions and 32 deletions

View File

@ -120,46 +120,20 @@ public class ManagedSelector extends ContainerLifeCycle implements Dumpable
{
// doStop might be called for a failed managedSelector,
// We do not want to wait twice, so we only stop once for each start
boolean timeout = false;
if (_started.compareAndSet(true,false))
{
if (getStopTimeout()>0)
{
// If we are graceful we can wait for connections to close
Set<Closeable> closed = new HashSet<>();
long now = System.nanoTime();
long wait_until = now+TimeUnit.MILLISECONDS.toNanos(getStopTimeout());
while(now<wait_until)
{
// Close any connection and wait for no endpoints in selector
CloseConnections close_connections = new CloseConnections(closed);
submit(close_connections);
if (close_connections._noEndPoints.await(100,TimeUnit.MILLISECONDS))
break;
now = System.nanoTime();
}
}
else
{
// Close connections, but only wait a single selector cycle for it to take effect
CloseConnections close_connections = new CloseConnections();
submit(close_connections);
close_connections._complete.await();
}
// Close connections, but only wait a single selector cycle for it to take effect
CloseConnections close_connections = new CloseConnections();
submit(close_connections);
close_connections._complete.await();
// Wait for any remaining endpoints to be closed and the selector to be stopped
StopSelector stop_selector = new StopSelector();
submit(stop_selector);
stop_selector._stopped.await();
timeout = getStopTimeout()>0 && stop_selector._forcedEndPointClose;
}
super.doStop();
if (timeout)
throw new TimeoutException("Unable to gracefully stop "+this);
super.doStop();
}
/**

View File

@ -58,6 +58,7 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -402,6 +403,7 @@ public class GracefulStopTest
* @throws Exception on test failure
*/
@Test
@Ignore // TODO disable while #2046 is fixed
public void testSlowCloseTinyGraceful() throws Exception
{
Log.getLogger(QueuedThreadPool.class).info("Expect some threads can't be stopped");
@ -413,6 +415,7 @@ public class GracefulStopTest
* @throws Exception on test failure
*/
@Test
@Ignore // TODO disable while #2046 is fixed
public void testSlowCloseGraceful() throws Exception
{
testSlowClose(5000,1000,Matchers.allOf(greaterThan(750L),lessThan(4999L)));