use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.
the class ProxyServletFailureTest method prepareServer.
private void prepareServer(HttpServlet servlet) throws Exception {
QueuedThreadPool executor = new QueuedThreadPool();
executor.setName("server");
server = new Server(executor);
serverConnector = new ServerConnector(server);
server.addConnector(serverConnector);
ServletContextHandler appCtx = new ServletContextHandler(server, "/", true, false);
ServletHolder appServletHolder = new ServletHolder(servlet);
appCtx.addServlet(appServletHolder, "/*");
server.start();
}
use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.
the class InsufficientThreadsDetectionTest method testConnectorUsesServerExecutorWithNotEnoughThreads.
@Test(expected = IllegalStateException.class)
public void testConnectorUsesServerExecutorWithNotEnoughThreads() throws Exception {
// server has 3 threads in the executor
_server = new Server(new QueuedThreadPool(3));
// connector will use executor from server because connectorPool is null
ThreadPool connectorPool = null;
// connector requires 7 threads(2 + 4 + 1)
ServerConnector connector = new ServerConnector(_server, connectorPool, null, null, 2, 4, new HttpConnectionFactory());
connector.setPort(0);
_server.addConnector(connector);
// should throw IllegalStateException because there are no required threads in server pool
_server.start();
}
use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.
the class InsufficientThreadsDetectionTest method testConnectorWithDedicatedExecutor.
@Test
public void testConnectorWithDedicatedExecutor() throws Exception {
// server has 3 threads in the executor
_server = new Server(new QueuedThreadPool(3));
// connector pool has 100 threads
ThreadPool connectorPool = new QueuedThreadPool(100);
// connector requires 7 threads(2 + 4 + 1)
ServerConnector connector = new ServerConnector(_server, connectorPool, null, null, 2, 4, new HttpConnectionFactory());
connector.setPort(0);
_server.addConnector(connector);
// should not throw exception because connector uses own executor, so its threads should not be counted
_server.start();
}
use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.
the class InsufficientThreadsDetectionTest method testCaseForMultipleConnectors.
// Github issue #586
@Test
public void testCaseForMultipleConnectors() throws Exception {
// server has 4 threads in the executor
_server = new Server(new QueuedThreadPool(4));
// first connector consumes all 4 threads from server pool
_server.addConnector(new ServerConnector(_server, null, null, null, 1, 1, new HttpConnectionFactory()));
// second connect also require 4 threads but uses own executor, so its threads should not be counted
final QueuedThreadPool connectorPool = new QueuedThreadPool(4, 4);
_server.addConnector(new ServerConnector(_server, connectorPool, null, null, 1, 1, new HttpConnectionFactory()));
// should not throw exception because limit was not overflown
_server.start();
}
use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.
the class LowResourcesMonitorTest method before.
@Before
public void before() throws Exception {
_threadPool = new QueuedThreadPool();
_threadPool.setMaxThreads(50);
_server = new Server(_threadPool);
_server.manage(_threadPool);
_server.addBean(new TimerScheduler());
_connector = new ServerConnector(_server);
_connector.setPort(0);
_connector.setIdleTimeout(35000);
_server.addConnector(_connector);
_server.setHandler(new DumpHandler());
_lowResourcesMonitor = new LowResourceMonitor(_server);
_lowResourcesMonitor.setLowResourcesIdleTimeout(200);
_lowResourcesMonitor.setMaxConnections(20);
_lowResourcesMonitor.setPeriod(900);
_server.addBean(_lowResourcesMonitor);
_server.start();
}
Aggregations