本文整理匯總了Java中org.eclipse.jetty.util.thread.QueuedThreadPool.setMaxThreads方法的典型用法代碼示例。如果您正苦於以下問題:Java QueuedThreadPool.setMaxThreads方法的具體用法?Java QueuedThreadPool.setMaxThreads怎麽用?Java QueuedThreadPool.setMaxThreads使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.util.thread.QueuedThreadPool
的用法示例。
在下文中一共展示了QueuedThreadPool.setMaxThreads方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createThreadPool
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
/**
* Creates a new thread pool for the server and hooks it's properties to the configuration events
*
* @return a new thread pool
*/
private static QueuedThreadPool createThreadPool() {
final QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMinThreads(Configuration.getInteger("jetty.threads.min", 10));
threadPool.setMaxThreads(Configuration.getInteger("jetty.threads.max", 80));
Configuration.addListener(ConfigChangeListener.forConfigProperty("jetty.threads.min", (k, v) -> {
threadPool.setMinThreads(Integer.parseInt(v));
restartThreadPool(threadPool);
LOG.info("Successfully resized threadpool " + k + "=" + v);
}));
Configuration.addListener(ConfigChangeListener.forConfigProperty("jetty.threads.max", (k, v) -> {
threadPool.setMaxThreads(Integer.parseInt(v));
restartThreadPool(threadPool);
LOG.info("Successfully resized threadpool " + k + "=" + v);
}));
return threadPool;
}
示例2: getDashboardJettyServer
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
/**
* Creates the Jetty server instance for the admin Dashboard and configures it with the @Named("DashboardContext").
* @param port where the service is available
* @param acceptorThreads no. of acceptors
* @param maxWorkerThreads max no. of worker threads
* @return Jetty Server instance
*/
@Named("DashboardJettyServer")
@Provides
@Singleton
Server getDashboardJettyServer(@Named("Dashboard.service.port") int port,
@Named("Dashboard.service.acceptors") int acceptorThreads,
@Named("Dashboard.service.selectors") int selectorThreads,
@Named("Dashboard.service.workers") int maxWorkerThreads,
@Named("DashboardContext") WebAppContext webappContext) {
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(maxWorkerThreads);
Server server = new Server(threadPool);
ServerConnector http = new ServerConnector(server, acceptorThreads, selectorThreads);
http.setPort(port);
server.addConnector(http);
server.setHandler(webappContext);
server.setStopAtShutdown(true);
return server;
}
示例3: setRuntimeParameters
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private void setRuntimeParameters(Server server, Application application) {
ThreadPool pool = server.getThreadPool();
if (pool instanceof QueuedThreadPool) {
QueuedThreadPool qtp = (QueuedThreadPool)pool;
cn.batchfile.getty.application.ThreadPool config = application.getThreadPool();
if (config != null && config.getMaxThreads() > 0) {
qtp.setMaxThreads(config.getMaxThreads());
}
if (config != null && config.getMinThreads() > 0) {
qtp.setMinThreads(config.getMinThreads());
}
if (config != null && config.getIdleTimeout() > 0) {
qtp.setIdleTimeout(config.getIdleTimeout());
}
}
}
示例4: assembleJettyServer
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
@Provides
private Server assembleJettyServer(JaxRsServerConfig config,
ServletContextHandler context) {
final QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(config.maxThreads());
final Server server = new Server(threadPool);
server.setHandler(context);
// Setup JMX
//MBeanContainer mbContainer=new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
//server.addBean(mbContainer);
setupConnectors(config, server);
return server;
}
示例5: createServer
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private Server createServer() {
final QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
final Server server = new Server(threadPool);
server.addBean(new ScheduledExecutorScheduler());
final ServerConnector http = createHttpServerConnector(server);
server.addConnector(http);
server.setHandler(createServletContextHandler());
server.setDumpAfterStart(false);
server.setDumpBeforeStop(false);
server.setStopAtShutdown(true);
return server;
}
示例6: createServer
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
protected Server createServer() {
final QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
final Server server = new Server(threadPool);
server.addBean(new ScheduledExecutorScheduler());
final HttpConfiguration http_config = createHttpConfigurationForHTTP();
// ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
// http.setPort(8080);
// http.setIdleTimeout(30000);
// server.addConnector(http);
server.setHandler(createServletContextHandler());
server.setDumpAfterStart(false);
server.setDumpBeforeStop(false);
server.setStopAtShutdown(true);
final HttpConfiguration https_config = createHttpConfigurationForHTTPS(http_config);
server.addConnector(createServerConnectorForHTTPS(server, https_config));
return server;
}
示例7: buildConnector
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
@Override
public Connector buildConnector(Server server, InetAddress inetAddress, int port) {
// create the NIO connector
SelectChannelConnector connector = new SelectChannelConnector();
if (inetAddress != null) {
connector.setHost(inetAddress.getHostAddress());
}
connector.setPort(port);
// turn on statistics
connector.setStatsOn(true);
// set whether or not to reuse the addresses
connector.setReuseAddress(true);
// configure the thread pool for accepting connections
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMinThreads(WEB_SERVER_MIN_THREADS);
threadPool.setMaxThreads(WEB_SERVER_MAX_THREADS);
threadPool.setName("simplejmx-web-server");
connector.setThreadPool(threadPool);
connector.setAcceptors(WEB_SERVER_MIN_THREADS);
return connector;
}
示例8: configureThreadPool
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private ThreadPool configureThreadPool(final int port) {
final QueuedThreadPool threadPool = new QueuedThreadPool(threadPoolCapacity);
threadPool.setMinThreads(minThreadCount);
threadPool.setMaxThreads(maxThreadCount);
threadPool.setName("Jetty thread pool [" + port + "]");
threadPool.setDetailedDump(true);
return threadPool;
}
示例9: startServer
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public static void startServer() throws ServletException {
QueuedThreadPool threadPool = new QueuedThreadPool(10);
threadPool.setDaemon(true);
threadPool.setMaxThreads(10);
Server server = new Server(threadPool);
server.addBean(new ScheduledExecutorScheduler("JettyScheduler", true), true);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory());
http.setPort(2992);
server.addConnector(http);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.setBaseResource(Resource.newClassPathResource("/org/lwjglx/debug/static"));
context.setWelcomeFiles(new String[] { "index.html" });
server.setHandler(context);
WebSocketUpgradeFilter wsfilter = WebSocketUpgradeFilter.configureContext(context);
// wsfilter.getFactory().getPolicy().setIdleTimeout(5000);
wsfilter.addMapping(new ServletPathSpec("/ws"), new ProfilingConnectionCreator());
ServletHolder holderDefault = new ServletHolder("default", DefaultServlet.class);
holderDefault.setInitParameter("dirAllowed", "true");
context.addServlet(holderDefault, "/");
try {
server.start();
} catch (Exception e) {
throw new AssertionError("Could not start profiling server", e);
}
}
示例10: start
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
@Override
public void start() {
if (isStarted()) {
return;
}
jettyServer = new org.eclipse.jetty.server.Server();
int port = serverConfig.getPort();
DispatcherServlet.addHttpHandler(port, new WebServiceHandler());
int threads = serverConfig.getServerBusinessPoolSize();
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName("JSF-WS-BZ");
threadPool.setDaemon(true);
threadPool.setMaxThreads(threads);
threadPool.setMinThreads(threads);
jettyServer.setThreadPool(threadPool);
SelectChannelConnector connector = new SelectChannelConnector();
connector.setHost(serverConfig.getHost());
connector.setPort(serverConfig.getPort());
jettyServer.addConnector(connector);
ServletHandler servletHandler = new ServletHandler();
ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
servletHolder.setInitOrder(2);
jettyServer.setHandler(servletHandler);
try {
jettyServer.start();
} catch (Exception e) {
throw new InitErrorException("Failed to start jetty server at port " + port
+ ", cause: " + e.getMessage(), e);
}
}
示例11: doStart
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
@Override
protected void doStart() throws Exception {
if (!hasThreadPool()) {
// if there is no thread pool then create a default thread pool using daemon threads
QueuedThreadPool qtp = new QueuedThreadPool();
// 16 max threads is the default in the http client
qtp.setMaxThreads(16);
qtp.setDaemon(true);
// let the thread names indicate they are from the client
qtp.setName("CamelJettyClient(" + ObjectHelper.getIdentityHashCode(this) + ")");
setThreadPoolOrExecutor(qtp);
}
super.doStart();
}
示例12: startProxy
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public int startProxy() throws Exception {
seenByProxy.clear();
InetAddress address = InetAddress.getLoopbackAddress();
httpProxyPort = NetworkUtils.getNextAvailablePort(address);
// Setup Threadpool
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
server = new Server(threadPool);
// HTTP Configuration
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https");
httpConfig.setSendServerVersion(true);
httpConfig.setSendDateHeader(false);
// Handler Structure
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {proxyHandler(), new DefaultHandler()});
server.setHandler(handlers);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
http.setPort(httpProxyPort);
server.addConnector(http);
server.start();
return httpProxyPort;
}
示例13: configureThreadPool
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
protected void configureThreadPool(QueuedThreadPool pool) {
// override QueuedThreadPool defaults
pool.setMaxThreads(jettyThreadPoolSettings.getMaxThreads());
pool.setMinThreads(jettyThreadPoolSettings.getMinThreads());
pool.setIdleTimeout(jettyThreadPoolSettings.getIdleTimeout());
pool.setDetailedDump(jettyThreadPoolSettings.isDetailedDump());
}
示例14: getAPIJettyServer
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
/**
* Creates the Jetty server instance for the Flux API endpoint.
* @param port where the service is available.
* @return Jetty Server instance
*/
@Named("APIJettyServer")
@Provides
@Singleton
Server getAPIJettyServer(@Named("Api.service.port") int port,
@Named("APIResourceConfig")ResourceConfig resourceConfig,
@Named("Api.service.acceptors") int acceptorThreads,
@Named("Api.service.selectors") int selectorThreads,
@Named("Api.service.workers") int maxWorkerThreads,
ObjectMapper objectMapper, MetricRegistry metricRegistry) throws URISyntaxException, UnknownHostException {
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(objectMapper);
resourceConfig.register(provider);
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(maxWorkerThreads);
Server server = new Server(threadPool);
ServerConnector http = new ServerConnector(server, acceptorThreads, selectorThreads);
http.setPort(port);
server.addConnector(http);
ServletContextHandler context = new ServletContextHandler(server, "/*");
ServletHolder servlet = new ServletHolder(new ServletContainer(resourceConfig));
context.addServlet(servlet, "/*");
final InstrumentedHandler handler = new InstrumentedHandler(metricRegistry);
handler.setHandler(context);
server.setHandler(handler);
server.setStopAtShutdown(true);
return server;
}
示例15: run
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public void run() {
try {
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(16);
Server server = new Server(threadPool);
ServletContextHandler handler = new ServletContextHandler();
handler.setContextPath("");
ResourceConfig config = new ResourceConfig(InstanceProviderResources.class).register(new Binder());
handler.addServlet(new ServletHolder(new ServletContainer(config)), "/*");
server.setHandler(handler);
// SSL Context Factory
SslContextFactory sslContextFactory = createSSLContextObject();
// SSL HTTP Configuration
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(10043);
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
// SSL Connector
ServerConnector sslConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(httpsConfig));
sslConnector.setPort(10043);
server.addConnector(sslConnector);
server.start();
server.join();
} catch (Exception e) {
System.err.println("*** " + e);
}
}