本文整理汇总了Java中org.mortbay.thread.QueuedThreadPool.setDaemon方法的典型用法代码示例。如果您正苦于以下问题:Java QueuedThreadPool.setDaemon方法的具体用法?Java QueuedThreadPool.setDaemon怎么用?Java QueuedThreadPool.setDaemon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.thread.QueuedThreadPool
的用法示例。
在下文中一共展示了QueuedThreadPool.setDaemon方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JettyHttpServer
import org.mortbay.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);
SelectChannelConnector connector = new SelectChannelConnector();
if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) {
connector.setHost(url.getHost());
}
connector.setPort(url.getPort());
server = new Server();
server.setThreadPool(threadPool);
server.addConnector(connector);
ServletHandler servletHandler = new ServletHandler();
ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
servletHolder.setInitOrder(2);
server.addHandler(servletHandler);
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: "
+ e.getMessage(), e);
}
}
示例2: BayeuxLoadGenerator
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
public BayeuxLoadGenerator() throws Exception
{
http=new HttpClient();
http.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
// http.setConnectorType(HttpClient.CONNECTOR_SOCKET);
http.setMaxConnectionsPerAddress(20000);
QueuedThreadPool pool = new QueuedThreadPool();
pool.setMaxThreads(500);
pool.setDaemon(true);
http.setThreadPool(pool);
http.start();
}
示例3: JettyHttpServer
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
public JettyHttpServer(URL url, final HttpHandler handler) {
super(url, handler);
DispatcherServlet.addHttpHandler(url.getParameter(Constants.BIND_PORT_KEY, 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);
SelectChannelConnector connector = new SelectChannelConnector();
String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost());
if (!url.isAnyHost() && NetUtils.isValidLocalHost(bindIp)) {
connector.setHost(bindIp);
}
connector.setPort(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()));
server = new Server();
server.setThreadPool(threadPool);
server.addConnector(connector);
ServletHandler servletHandler = new ServletHandler();
ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
servletHolder.setInitOrder(2);
server.addHandler(servletHandler);
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + url.getParameter(Constants.BIND_IP_KEY) + ":" + url.getParameter(Constants.BIND_PORT_KEY) + ", cause: "
+ e.getMessage(), e);
}
}
示例4: createHttpServer
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
private Server createHttpServer(int port, String name, int maxThreads, int maxIdleTimeMs) throws BioNimbusException {
try {
// Creates HTTP Server on int port
Server httpServer = new Server(port);
SpecificResponder responder = new SpecificResponder(BioProto.class, bioProto);
// QueuedThreadPool is jetty's thread pool implementation;
// this lets us give it a name.
QueuedThreadPool qtp = new QueuedThreadPool();
qtp.setName(name);
qtp.setDaemon(true);
qtp.setMaxThreads(maxThreads);
qtp.setMaxIdleTimeMs(maxIdleTimeMs);
httpServer.setThreadPool(qtp);
// Creates Responder Servlet
Servlet servlet = new ResponderServlet(responder);
// Creates Context adding a holder
new Context(httpServer, "/").addServlet(new ServletHolder(servlet), "/*");
// Return the early created Server
return httpServer;
} catch (Exception e) {
throw new BioNimbusException(e);
}
}
示例5: go
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
public void go() {
QueuedThreadPool pool = new QueuedThreadPool();
pool.setMinThreads(2); // debug server doesn't need many threads.
pool.setMaxThreads(10);
pool.setName("DebugServer(port" + port + ")");
pool.setDaemon(true);
server.setThreadPool(pool);
SocketConnector connector = new SocketConnector();
connector.setPort(port);
connector.setHost(host);
connector.setMaxIdleTime(60000); // 1 min
server.addConnector(connector);
context.setContextPath("/");
context.setBaseResource(Resource.newClassPathResource("/org/cloudera/stethoscope"));
server.setHandler(context);
addServlet(new DefaultServlet(), "/");
addServlet(new DataServlet(), "/json/*");
addServlet(new TracerServlet(inst), "/tracer/*");
addServlet(new EvaluateServlet(), "/evaluate");
addServlet(new PoorMansProfileServlet(), "/poorMansProfiler");
addServlet(new JMXJsonServlet(), "/jmx");
// addServlet(new LoggerServlet(), "/logging");
try {
server.start();
} catch (Exception e) {
// avoiding logging in this context.
e.printStackTrace(System.err);
}
}
示例6: JettyHttpServer
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
public JettyHttpServer(URL url, final HttpHandler handler){
super(url, handler);
// modified by lishen
this.url = url;
// TODO we should leave this setting to slf4j
Log.setLog(new StdErrLog());
Log.getLog().setDebugEnabled(false);
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);
SelectChannelConnector connector = new SelectChannelConnector();
if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) {
connector.setHost(url.getHost());
}
connector.setPort(url.getPort());
server = new Server();
server.setThreadPool(threadPool);
server.addConnector(connector);
ServletHandler servletHandler = new ServletHandler();
ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
servletHolder.setInitOrder(2);
// modified by lishen
// dubbo's original impl can't support the use of ServletContext
// server.addHandler(servletHandler);
// TODO Context.SESSIONS is the best option here?
Context context = new Context(server, "/", Context.SESSIONS);
context.setServletHandler(servletHandler);
ServletManager.getInstance().addServletContext(url.getPort(), context.getServletContext());
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: "
+ e.getMessage(), e);
}
}
示例7: initializeWebServer
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {contexts, requestLogHandler});
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}
示例8: JettyHttpServer
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
public JettyHttpServer(URL url, final HttpHandler handler){
super(url, handler);
// modified by lishen
this.url = url;
// TODO we should leave this setting to slf4j
Log.setLog(new StdErrLog());
Log.getLog().setDebugEnabled(false);
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);
SelectChannelConnector connector = new SelectChannelConnector();
if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) {
connector.setHost(url.getHost());
}
connector.setPort(url.getPort());
server = new Server();
server.setThreadPool(threadPool);
server.addConnector(connector);
ServletHandler servletHandler = new ServletHandler();
ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
servletHolder.setInitOrder(2);
// modified by lishen
// dubbo's original impl can't support the use of ServletContext
// server.addHandler(servletHandler);
// TODO Context.SESSIONS is the best option here?
Context context = new Context(server, "/", Context.SESSIONS);
context.setServletHandler(servletHandler);
BaseContext.CTX.addServletContext(url.getPort(), context.getServletContext());
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: "
+ e.getMessage(), e);
}
}
示例9: initializeWebServer
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws FileNotFoundException, IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {contexts, requestLogHandler});
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}
示例10: HttpServer
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
/**
* Create a status server on the given port.
* The jsp scripts are taken from src/webapps/<name>.
* @param name The name of the server
* @param port The port to use on the server
* @param findPort whether the server should start at the given port and
* increment by 1 until it finds a free port.
* @param conf Configuration
*/
public HttpServer(String name, String bindAddress, int port,
boolean findPort, Configuration conf) throws IOException {
webServer = new Server();
this.findPort = findPort;
listener = createBaseListener(conf);
listener.setHost(bindAddress);
listener.setPort(port);
webServer.addConnector(listener);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// Set the timeout for the threadpool to exit (default 1 second)
int maxStopTime = conf.getInt(HTTP_THREADPOOL_MAX_STOP_TIME, 1000);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 254).
QueuedThreadPool threadPool = maxThreads == -1 ?
new QueuedThreadPool() : new QueuedThreadPool(maxThreads);
threadPool.setMaxStopTimeMs(maxStopTime);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
final String appDir = getWebAppsPath();
ContextHandlerCollection contexts = new ContextHandlerCollection();
webServer.setHandler(contexts);
webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setWar(appDir + "/" + name);
webAppContext.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
for(FilterInitializer c : initializers) {
c.initFilter(this);
}
}
addDefaultServlets();
}
示例11: initializeWebServer
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws FileNotFoundException, IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { requestLogHandler, contexts });
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}
示例12: initializeWebServer
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {contexts, requestLogHandler});
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
Map<String, String> xFrameParams = new HashMap<>();
xFrameParams.put(X_FRAME_ENABLED,
String.valueOf(this.xFrameOptionIsEnabled));
xFrameParams.put(X_FRAME_VALUE, this.xFrameOption.toString());
addGlobalFilter("safety", QuotingInputFilter.class.getName(), xFrameParams);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}
示例13: initializeWebServer
import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
private void initializeWebServer(String name, String hostName,
Configuration conf, String[] pathSpecs)
throws FileNotFoundException, IOException {
Preconditions.checkNotNull(webAppContext);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 250).
QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
: new QueuedThreadPool(maxThreads);
threadPool.setDaemon(true);
webServer.setThreadPool(threadPool);
SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
if (sm instanceof AbstractSessionManager) {
AbstractSessionManager asm = (AbstractSessionManager)sm;
asm.setHttpOnly(true);
asm.setSecureCookies(true);
}
ContextHandlerCollection contexts = new ContextHandlerCollection();
RequestLog requestLog = HttpRequestLog.getRequestLog(name);
if (requestLog != null) {
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { requestLogHandler, contexts });
webServer.setHandler(handlers);
} else {
webServer.setHandler(contexts);
}
final String appDir = getWebAppsPath(name);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir, conf);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
conf = new Configuration(conf);
conf.set(BIND_ADDRESS, hostName);
for (FilterInitializer c : initializers) {
c.initFilter(this, conf);
}
}
addDefaultServlets();
if (pathSpecs != null) {
for (String path : pathSpecs) {
LOG.info("adding path spec: " + path);
addFilterPathMapping(path, webAppContext);
}
}
}