use of org.eclipse.jetty.util.thread.ThreadPool 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.ThreadPool 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.ThreadPool in project zm-mailbox by Zimbra.
the class ContextPathBasedThreadPoolBalancerFilter method init.
@Override
public void init(FilterConfig filterConfig) throws ServletException {
suspendMs = DEFAULT_SUSPEND_MS;
String str = StringUtils.trimToNull(filterConfig.getInitParameter(SUSPEND_INIT_PARAM));
if (str != null) {
suspendMs = Integer.parseInt(str);
}
str = StringUtils.trimToNull(filterConfig.getInitParameter(RULES_INIT_PARAM));
parse(str);
ZimbraLog.misc.info("Initialized with %s", str);
ThreadPool threadPool = JettyMonitor.getThreadPool();
if (threadPool instanceof QueuedThreadPool) {
queuedThreadPool = (QueuedThreadPool) threadPool;
ZimbraLog.misc.info("Thread pool was configured to max=" + queuedThreadPool.getMaxThreads());
}
}
use of org.eclipse.jetty.util.thread.ThreadPool in project dropwizard by dropwizard.
the class SimpleServerFactory method build.
@Override
public Server build(Environment environment) {
// ensures that the environment is configured before the server is built
configure(environment);
printBanner(environment.getName());
final ThreadPool threadPool = createThreadPool(environment.metrics());
final Server server = buildServer(environment.lifecycle(), threadPool);
final Handler applicationHandler = createAppServlet(server, environment.jersey(), environment.getObjectMapper(), environment.getValidator(), environment.getApplicationContext(), environment.getJerseyServletContainer(), environment.metrics());
final Handler adminHandler = createAdminServlet(server, environment.getAdminContext(), environment.metrics(), environment.healthChecks());
final Connector conn = connector.build(server, environment.metrics(), environment.getName(), null);
server.addConnector(conn);
final ContextRoutingHandler routingHandler = new ContextRoutingHandler(ImmutableMap.of(applicationContextPath, applicationHandler, adminContextPath, adminHandler));
final Handler gzipHandler = buildGzipHandler(routingHandler);
server.setHandler(addStatsHandler(addRequestLog(server, gzipHandler, environment.getName())));
return server;
}
use of org.eclipse.jetty.util.thread.ThreadPool in project dropwizard by dropwizard.
the class HttpConnectorFactoryTest method testDefaultAcceptQueueSize.
@Test
public void testDefaultAcceptQueueSize() throws Exception {
HttpConnectorFactory http = new HttpConnectorFactory();
http.setBindHost("127.0.0.1");
http.setAcceptorThreads(Optional.of(1));
http.setSelectorThreads(Optional.of(2));
http.setSoLingerTime(Duration.seconds(30));
Server server = new Server();
MetricRegistry metrics = new MetricRegistry();
ThreadPool threadPool = new QueuedThreadPool();
ServerConnector connector = (ServerConnector) http.build(server, metrics, "test-http-connector", threadPool);
assertThat(connector.getAcceptQueueSize()).isEqualTo(NetUtil.getTcpBacklog());
connector.stop();
}
Aggregations