当前位置: 首页>>代码示例>>Java>>正文


Java QueuedThreadPool.setMaxThreads方法代码示例

本文整理汇总了Java中org.mortbay.thread.QueuedThreadPool.setMaxThreads方法的典型用法代码示例。如果您正苦于以下问题:Java QueuedThreadPool.setMaxThreads方法的具体用法?Java QueuedThreadPool.setMaxThreads怎么用?Java QueuedThreadPool.setMaxThreads使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mortbay.thread.QueuedThreadPool的用法示例。


在下文中一共展示了QueuedThreadPool.setMaxThreads方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:34,代码来源:JettyHttpServer.java

示例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();

}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:16,代码来源:BayeuxLoadGenerator.java

示例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);
    }
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:36,代码来源:JettyHttpServer.java

示例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);
    }
}
 
开发者ID:bionimbuz,项目名称:Bionimbuz,代码行数:29,代码来源:AvroServer.java

示例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);
  }
}
 
开发者ID:philz,项目名称:stethoscope,代码行数:35,代码来源:StethoscopeWebServer.java

示例6: startInner

import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
@Override
public void startInner() {
    try {
        Connector connector = new SelectChannelConnector();
        connector.setLowResourceMaxIdleTime(3000);
        connector.setPort(this.port);
        QueuedThreadPool threadPool = new QueuedThreadPool();
        threadPool.setName("VoldemortHttp");
        threadPool.setMaxThreads(this.numberOfThreads);
        Server httpServer = new Server();
        httpServer.setConnectors(new Connector[] { connector });
        httpServer.setThreadPool(threadPool);
        httpServer.setSendServerVersion(false);
        httpServer.setSendDateHeader(false);
        Context context = new Context(httpServer, "/", Context.NO_SESSIONS);
        context.setAttribute(VoldemortServletContextListener.SERVER_KEY, server);
        context.setAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY,
                             velocityEngine);
        context.addServlet(new ServletHolder(new AdminServlet(server, velocityEngine)),
                           "/admin");
        context.addServlet(new ServletHolder(new StoreServlet(requestHandler)), "/stores");
        context.addServlet(new ServletHolder(new ReadOnlyStoreManagementServlet(server,
                                                                                velocityEngine)),
                           "/read-only/mgmt");
        context.addServlet(new ServletHolder(new StatusServlet(server, velocityEngine)),
                           "/server-status");
        this.context = context;
        this.httpServer = httpServer;
        this.httpServer.start();
        logger.info("HTTP service started on port " + this.port);
    } catch(Exception e) {
        throw new VoldemortException(e);
    }
}
 
开发者ID:we7,项目名称:voldemort,代码行数:35,代码来源:HttpService.java

示例7: setThreads

import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
/**
 * Set the min, max number of worker threads (simultaneous connections).
 */
public void setThreads(int min, int max) {
  QueuedThreadPool pool = (QueuedThreadPool) webServer.getThreadPool();
  pool.setMinThreads(min);
  pool.setMaxThreads(max);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:HttpServer2.java

示例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);
        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);
        }
    }
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:47,代码来源:JettyHttpServer.java

示例9: setThreads

import org.mortbay.thread.QueuedThreadPool; //导入方法依赖的package包/类
/**
 * Set the min, max number of worker threads (simultaneous connections).
 */
public void setThreads(int min, int max) {
  QueuedThreadPool pool = (QueuedThreadPool) webServer.getThreadPool() ;
  pool.setMinThreads(min);
  pool.setMaxThreads(max);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:HttpServer.java

示例10: 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);
        }
    }
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:47,代码来源:JettyHttpServer.java


注:本文中的org.mortbay.thread.QueuedThreadPool.setMaxThreads方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。