本文整理匯總了Java中org.eclipse.jetty.util.thread.QueuedThreadPool.setDaemon方法的典型用法代碼示例。如果您正苦於以下問題:Java QueuedThreadPool.setDaemon方法的具體用法?Java QueuedThreadPool.setDaemon怎麽用?Java QueuedThreadPool.setDaemon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.util.thread.QueuedThreadPool
的用法示例。
在下文中一共展示了QueuedThreadPool.setDaemon方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createRedirectorServer
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private Server createRedirectorServer() {
int unsecurePort = conf.get(HTTP_PORT_KEY, HTTP_PORT_DEFAULT);
String hostname = conf.get(HTTP_BIND_HOST, HTTP_BIND_HOST_DEFAULT);
QueuedThreadPool qtp = new QueuedThreadPool(25);
qtp.setName(serverName + "Redirector");
qtp.setDaemon(true);
Server server = new Server(qtp);
InetSocketAddress addr = new InetSocketAddress(hostname, unsecurePort);
ServerConnector connector = new ServerConnector(server);
connector.setHost(addr.getHostName());
connector.setPort(addr.getPort());
server.setConnectors(new Connector[]{connector});
ServletContextHandler context = new ServletContextHandler();
context.addServlet(new ServletHolder(new RedirectorServlet()), "/*");
context.setContextPath("/");
server.setHandler(context);
return server;
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: init
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public static void init() {
QueuedThreadPool queuedThreadPool = new QueuedThreadPool();
queuedThreadPool.setDaemon(true);
jetty = new Server(queuedThreadPool);
HandlerCollection handlerCollection = new HandlerCollection(true);
handlerCollection.addHandler(new JettyHandler(RESPONSE_STRING, PATH_RESPONSE_STRING));
jetty.setHandler(handlerCollection);
}
示例5: 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();
}
示例6: createServer
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private Server createServer() {
port = isSSLEnabled() ?
conf.get(HTTPS_PORT_KEY, HTTPS_PORT_DEFAULT) :
conf.get(HTTP_PORT_KEY, HTTP_PORT_DEFAULT);
String hostname = conf.get(HTTP_BIND_HOST, HTTP_BIND_HOST_DEFAULT);
QueuedThreadPool qtp = new QueuedThreadPool(conf.get(HTTP_MAX_THREADS, HTTP_MAX_THREADS_DEFAULT));
qtp.setName(serverName);
qtp.setDaemon(true);
Server server = new Server(qtp);
httpConf = configureForwardRequestCustomizer(httpConf);
if (!isSSLEnabled()) {
InetSocketAddress addr = new InetSocketAddress(hostname, port);
ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConf));
connector.setHost(addr.getHostName());
connector.setPort(addr.getPort());
server.setConnectors(new Connector[]{connector});
} else {
//Create a connector for HTTPS
httpConf.addCustomizer(new SecureRequestCustomizer());
SslContextFactory sslContextFactory = createSslContextFactory();
ServerConnector httpsConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, "http/1.1"),
new HttpConnectionFactory(httpConf));
httpsConnector.setPort(port);
httpsConnector.setHost(hostname);
server.setConnectors(new Connector[]{httpsConnector});
}
return server;
}
示例7: JettyHttpServer
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public JettyHttpServer(URL url, final HttpHandler handler) {
super(url, handler);
DispatcherServlet.addHttpHandler(url.getPort(), handler);
int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setDaemon(true);
threadPool.setMaxThreads(threads);
threadPool.setMinThreads(threads);
server = new Server(threadPool);
// HTTP connector
ServerConnector connector = new ServerConnector(server);
if (!url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) {
connector.setHost(url.getHost());
}
connector.setPort(url.getPort());
// connector.setIdleTimeout(30000);
server.addConnector(connector);
ServletHandler servletHandler = new ServletHandler();
ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
servletHolder.setInitOrder(2);
server.insertHandler(servletHandler);
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: "
+ e.getMessage(), e);
}
}
示例8: start
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
void start() {
if (server != null) {
throw new RuntimeException("Server is already started");
} else {
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setDaemon(true);
server = new Server(threadPool);
server.manage(threadPool);
final ServerConnector connector = new ServerConnector(server);
connector.setIdleTimeout(60 * 1000);
connector.setSoLingerTime(-1);
connector.setPort(0);
server.setConnectors(new Connector[] { connector });
final ResourceHandler resHandler = new ResourceHandler();
resHandler.setResourceBase(resourceBase.getAbsolutePath());
final HandlerList handlerList = new HandlerList();
handlerList.setHandlers(new Handler[] {resHandler, new DefaultHandler()});
server.setHandler(handlerList);
try {
server.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
port = connector.getLocalPort();
}
}
示例9: RestChangeIngestor
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public RestChangeIngestor() {
QueuedThreadPool queuedThreadPool = new QueuedThreadPool();
queuedThreadPool.setDaemon(true);
jetty = new Server(queuedThreadPool);
}
示例10: init
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public List<Stage.ConfigIssue> init(Stage.Context context) {
List<Stage.ConfigIssue> issues = new ArrayList<>();
try {
int maxThreads = getJettyServerMaxThreads();
int minThreads = getJettyServerMinThreads();
QueuedThreadPool threadPool =
new QueuedThreadPool(maxThreads, minThreads, 60000, new ArrayBlockingQueue<Runnable>(maxThreads));
threadPool.setName("http-receiver-server:" + context.getPipelineInfo().get(0).getInstanceName());
threadPool.setDaemon(true);
Server server = new Server(threadPool);
ServerConnector connector;
if (configs.isTlsEnabled()) {
LOG.debug("Configuring HTTPS");
HttpConfiguration httpsConf = new HttpConfiguration();
httpsConf.addCustomizer(new SecureRequestCustomizer());
SslContextFactory sslContextFactory = new SslContextFactory();
TlsConfigBean tlsConfig = configs.getTlsConfigBean();
sslContextFactory.setKeyStorePath(tlsConfig.keyStoreFilePath);
sslContextFactory.setKeyStoreType(tlsConfig.keyStoreType.getJavaValue());
sslContextFactory.setKeyStorePassword(tlsConfig.keyStorePassword.get());
sslContextFactory.setKeyManagerPassword(tlsConfig.keyStorePassword.get());
sslContextFactory.setIncludeProtocols(tlsConfig.getFinalProtocols());
sslContextFactory.setIncludeCipherSuites(tlsConfig.getFinalCipherSuites());
connector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, "http/1.1"),
new HttpConnectionFactory(httpsConf)
);
} else {
LOG.debug("Configuring HTTP");
connector = new ServerConnector(server);
}
connector.setPort(configs.getPort());
server.setConnectors(new Connector[]{connector});
ServletContextHandler contextHandler = new ServletContextHandler();
// CORS Handling
FilterHolder crossOriginFilter = new FilterHolder(CrossOriginFilter.class);
Map<String, String> params = new HashMap<>();
params.put(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
params.put(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "*");
crossOriginFilter.setInitParameters(params);
contextHandler.addFilter(crossOriginFilter, "/*", EnumSet.of(DispatcherType.REQUEST));
addReceiverServlet(context, contextHandler);
contextHandler.setContextPath("/");
server.setHandler(contextHandler);
server.start();
LOG.debug("Running, port '{}', TLS '{}'", configs.getPort(), configs.isTlsEnabled());
httpServer = server;
} catch (Exception ex) {
issues.add(context.createConfigIssue("HTTP", "", HttpServerErrors.HTTP_SERVER_ORIG_20, ex.toString()));
}
return issues;
}
示例11: start
import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public void start() throws Exception {
int numberOfThreads = getJettyServerMinimumThreads();
QueuedThreadPool threadPool = new QueuedThreadPool(numberOfThreads, numberOfThreads, 60000,
new ArrayBlockingQueue<Runnable>(20));
threadPool.setName("sdcipc-server");
threadPool.setDaemon(true);
Server server = new Server(threadPool);
ServerConnector connector;
if (configs.tlsConfigBean.isEnabled()) {
LOG.debug("Configuring over HTTPS");
HttpConfiguration httpsConf = new HttpConfiguration();
httpsConf.addCustomizer(new SecureRequestCustomizer());
SslContextFactory sslContextFactory = new SslContextFactory();
final TlsConfigBean tlsConfig = configs.getTlsConfigBean();
sslContextFactory.setKeyStore(tlsConfig.getKeyStore());
sslContextFactory.setKeyStorePassword(tlsConfig.keyStorePassword.get());
sslContextFactory.setKeyManagerPassword(tlsConfig.keyStorePassword.get());
sslContextFactory.setSslContext(tlsConfig.getSslContext());
sslContextFactory.setIncludeProtocols(tlsConfig.getFinalProtocols());
sslContextFactory.setIncludeCipherSuites(tlsConfig.getFinalCipherSuites());
connector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"),
new HttpConnectionFactory(httpsConf));
} else {
LOG.debug("Configuring over HTTP");
connector = new ServerConnector(server);
}
connector.setPort(configs.port);
server.setConnectors(new Connector[]{connector});
servlet = new IpcServlet(context, configs, queue);
ServletContextHandler contextHandler = new ServletContextHandler();
contextHandler.addFilter(DisableTraceFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
contextHandler.addServlet(new ServletHolder(new PingServlet()), Constants.PING_PATH);
contextHandler.addServlet(new ServletHolder(servlet), Constants.IPC_PATH);
contextHandler.setContextPath("/");
server.setHandler(contextHandler);
server.start();
LOG.info("Running, port '{}', TLS '{}'", configs.port, configs.tlsConfigBean.isEnabled());
httpServer = server;
}