private static void setupHttpServer(int httpPort, int httpsPort) throws Exception{ QueuedThreadPool pool = new QueuedThreadPool(); pool.setMaxThreads(500); pool.start(); LoklakServer.server = new Server(pool); LoklakServer.server.setStopAtShutdown(true);
@Test public void shouldHaveConfigurableJettyThreadPoolSize() throws Exception { Jetty9WebServer server = new Jetty9WebServer( NullLogProvider.getInstance(), Config.defaults(), NetworkConnectionTracker.NO_OP ); int numCores = 1; int configuredMaxThreads = 12; // 12 is the new min max Threads value, for one core int acceptorThreads = 1; // In this configuration, 1 thread will become an acceptor... int selectorThreads = 1; // ... and 1 thread will become a selector... int jobThreads = configuredMaxThreads - acceptorThreads - selectorThreads; // ... and the rest are job threads server.setMaxThreads( numCores ); server.setHttpAddress( new ListenSocketAddress( "localhost", 0 ) ); try { server.start(); QueuedThreadPool threadPool = (QueuedThreadPool) server.getJetty().getThreadPool(); threadPool.start(); CountDownLatch startLatch = new CountDownLatch( jobThreads ); CountDownLatch endLatch = loadThreadPool( threadPool, configuredMaxThreads + 1, startLatch ); startLatch.await(); // Wait for threadPool to create threads int threads = threadPool.getThreads(); assertEquals( "Wrong number of threads in pool", configuredMaxThreads, threads ); endLatch.countDown(); } finally { server.stop(); } }
public void startThreadPool() throws Exception { threadPool.start(); }
public void start() throws Exception { threadPool.start(); for (Iterator<Server> it = servers.values().iterator(); it.hasNext(); ) { Server server = it.next(); server.start(); } }
private static QueuedThreadPool createExecutor(String name, int minThreads, int maxThreads) { try { QueuedThreadPool pool = new QueuedThreadPool(maxThreads, minThreads, 60000, null); pool.setName("http-client-" + name); pool.setDaemon(true); pool.start(); pool.setStopTimeout(2000); return pool; } catch (Exception e) { throwIfUnchecked(e); throw new RuntimeException(e); } }
private static QueuedThreadPool createExecutor(String name, int minThreads, int maxThreads) { try { QueuedThreadPool pool = new QueuedThreadPool(maxThreads, minThreads, 60000, null); pool.setName("http-client-" + name); pool.setDaemon(true); pool.start(); pool.setStopTimeout(2000); pool.setDetailedDump(true); return pool; } catch (Exception e) { throwIfUnchecked(e); throw new RuntimeException(e); } }
qtp.start(); } catch (Exception e) { throw new RuntimeCamelException("Error starting JettyWebSocketServer thread pool: " + qtp, e);