當前位置: 首頁>>代碼示例>>Java>>正文


Java SelectChannelConnector.setThreadPool方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.server.nio.SelectChannelConnector.setThreadPool方法的典型用法代碼示例。如果您正苦於以下問題:Java SelectChannelConnector.setThreadPool方法的具體用法?Java SelectChannelConnector.setThreadPool怎麽用?Java SelectChannelConnector.setThreadPool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.server.nio.SelectChannelConnector的用法示例。


在下文中一共展示了SelectChannelConnector.setThreadPool方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createConnector

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
 * Creates an http connector.
 * 
 * @param useNIO
 * @param port
 * @param threadPoolSize
 * @return an http connector
 */
private Connector createConnector(boolean useNIO, int port, int threadPoolSize) {
	Connector connector;
	if (useNIO) {
		logger.info("Setting up NIO SelectChannelConnector on port " + port);
		SelectChannelConnector nioconn = new SelectChannelConnector();
		nioconn.setSoLingerTime(-1);
		if (threadPoolSize > 0) {
			nioconn.setThreadPool(new QueuedThreadPool(threadPoolSize));
		}
		connector = nioconn;
	} else {
		logger.info("Setting up SocketConnector on port " + port);
		SocketConnector sockconn = new SocketConnector();
		if (threadPoolSize > 0) {
			sockconn.setThreadPool(new QueuedThreadPool(threadPoolSize));
		}
		connector = sockconn;
	}

	connector.setPort(port);
	connector.setMaxIdleTime(30000);
	return connector;
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:32,代碼來源:GitBlitServer.java

示例2: TestServer

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public TestServer() {
    mJsonMapper = new ObjectMapper();

    mServletHandler = new ServletHandler();
    mServletHandler.addServletWithMapping(TestServletWs.class, "/ws");
    mServletHandler.addServletWithMapping(TestServletHttp.class, "/http");

    mConnector = new SelectChannelConnector();
    mConnector.setThreadPool(new QueuedThreadPool(10));
    mConnector.setHost("localhost");
    mConnector.setPort(0);

    mServer = new Server();
    mServer.setThreadPool(new QueuedThreadPool(10));
    mServer.setHandler(mServletHandler);
    mServer.setConnectors(new Connector[]{mConnector});
}
 
開發者ID:promovicz,項目名稱:better-jsonrpc,代碼行數:18,代碼來源:TestServer.java

示例3: createConnector

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
 * Creates an http connector.
 * 
 * @param useNIO
 * @param port
 * @return an http connector
 */
private Connector createConnector(boolean useNIO, int port) {
	Connector connector;
	if (useNIO) {
		logger.info("Setting up NIO SelectChannelConnector on port " + port);
		SelectChannelConnector nioconn = new SelectChannelConnector();
		nioconn.setSoLingerTime(-1);
		nioconn.setThreadPool(new QueuedThreadPool(20));
		connector = nioconn;
	} else {
		logger.info("Setting up SocketConnector on port " + port);
		SocketConnector sockconn = new SocketConnector();
		connector = sockconn;
	}

	connector.setPort(port);
	connector.setMaxIdleTime(30000);
	return connector;
}
 
開發者ID:BullShark,項目名稱:IRCBlit,代碼行數:26,代碼來源:GitBlitServer.java

示例4: buildConnector

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的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;
}
 
開發者ID:j256,項目名稱:simplejmx,代碼行數:25,代碼來源:Jetty8ConnectorFactory.java

示例5: init

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
 * Method used to initialize and start the SSE server
 */
public static void init()
{
	Server server = new Server();
	SelectChannelConnector connector = new SelectChannelConnector();
	connector.setPort(8070);
	connector.setAcceptors(3);
	connector.setThreadPool(new QueuedThreadPool(50));
	connector.setMaxIdleTime(72*60*60*1000);
	connector.setAcceptQueueSize(50000);
	connector.setRequestBufferSize(50000);
	connector.setResponseBufferSize(50000);
	server.setConnectors(new Connector[] { connector });
	ServletContextHandler context = new ServletContextHandler(
			ServletContextHandler.SESSIONS);
	context.setContextPath("/");
	//context.setResourceBase(System.getProperty("java.io.tmpdir"));

	ServletHolder requestServletHolder = new ServletHolder(EventServer.class);
	context.addServlet(requestServletHolder, "/response");

	ServletHolder notificationServletHolder = new ServletHolder(NotificationServer.class);
	context.addServlet(notificationServletHolder, "/notification");


	server.setHandler(context);
	context.addEventListener(new ConfigureService());
	context.addEventListener(new NotificationService());

	try {
		server.start();
		LOG.info("Server Started");
		server.join();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}


}
 
開發者ID:opendaylight,項目名稱:fpc,代碼行數:43,代碼來源:JettyServer.java

示例6: buildJettyServer

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private static Server buildJettyServer(int serverPort)
        throws Exception {

    Server server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(serverPort);
    connector.setAcceptQueueSize(100);
    connector.setThreadPool(new QueuedThreadPool(5));
    server.addConnector(connector);

    ContextHandlerCollection contexts = new ContextHandlerCollection();
    server.setHandler(contexts);
    server.setGracefulShutdown(1000);
    server.setStopAtShutdown(true);

    ServletContextHandler handler = new ServletContextHandler(contexts, "/", ServletContextHandler.SESSIONS);
    handler.addEventListener(new SessionListener());
    handler.addServlet(TestServlet.class, "/");
    handler.setLogger(null);

    FilterHolder filterHolder = new FilterHolder(WebFilter.class);
    filterHolder.setInitParameter("sticky-session", "false");
    filterHolder.setInitParameter("map-name", "default");
    filterHolder.setInitParameter("instance-name", "client");
    filterHolder.setInitParameter("shutdown-on-destroy", "true");
    filterHolder.setInitParameter("use-client", "true");
    filterHolder.setInitParameter("deferred-write", "false");
    handler.addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));

    server.start();
    return server;
}
 
開發者ID:noctarius,項目名稱:hazelcast-unaware-serialization,代碼行數:33,代碼來源:UnawareSerialization.java

示例7: main

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
 * Entry point of Ephyra. Initializes the engine and starts the web service interface.
 * 
 * @param args command line arguments are ignored
 */
public static void main(String[] args) throws Exception {
	// enable output of status and error messages
	MsgPrinter.enableStatusMsgs(true);
	MsgPrinter.enableErrorMsgs(true);
	
	// set log file and enable logging
	Logger.setLogfile("log/OpenEphyra");
	Logger.enableLogging(true);
	

       String addr = "localhost";
       int port = 8080;
       if (args.length > 1) {
           addr = args[0];
           port = Integer.parseInt(args[1]);
       }
       int NTHREADS = Integer.parseInt(System.getenv("THREADS"));

       Server server = new Server();
       SelectChannelConnector con1 = new SelectChannelConnector();
       con1.setHost(addr);
       con1.setPort(port);
       con1.setThreadPool(new QueuedThreadPool(NTHREADS));
       con1.setMaxIdleTime(30000);
       con1.setRequestHeaderSize(8192);

       server.setConnectors(new Connector[]{con1});
	server.setHandler(new OpenEphyraServer()); 
 
	server.start();
	server.join();
}
 
開發者ID:claritylab,項目名稱:lucida,代碼行數:38,代碼來源:OpenEphyraServer.java

示例8: create

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public static Server create(HttpConfiguration configuration) throws Exception {
    Server server = new Server();

    SelectChannelConnector connector = new InstrumentedSelectChannelConnector(configuration.listenAddress.getPort());
    connector.setHost(configuration.listenAddress.getHostName());
    QueuedThreadPool queuedThreadPool = new InstrumentedQueuedThreadPool();
    queuedThreadPool.setMaxThreads(configuration.numHttpWorkers);
    connector.setThreadPool(queuedThreadPool);
    queuedThreadPool.start();

    server.setConnectors(new Connector[]{connector});
    server.setSendServerVersion(true);
    server.setSendDateHeader(true);
    server.setStopAtShutdown(true);
    server.setGracefulShutdown((int) TimeUnit.SECONDS.toMillis(5));

    ServletContextHandler root = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
    root.setContextPath("/");

    server.setHandler(new InstrumentedHandler(root));

    // Jersey
    root.addServlet(buildJerseyServlet(), "/*");

    NCSARequestLog requestLog = new NCSARequestLog(configuration.httpLogFileName);
    requestLog.setRetainDays(90);
    requestLog.setAppend(true);
    requestLog.setExtended(true);
    requestLog.setLogTimeZone("GMT");
    requestLog.setLogLatency(true);
    requestLog.setLogDispatch(true);

    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(requestLog);
    root.setHandler(requestLogHandler);

    connector.setStatsOn(true);
    StatisticsHandler statisticsHandler = new StatisticsHandler();
    statisticsHandler.setServer(server);

    requestLogHandler.setHandler(statisticsHandler);

    // Setup JMX
    MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
    server.getContainer().addEventListener(mbContainer);
    mbContainer.addBean(statisticsHandler);

    return server;
}
 
開發者ID:chriskearney,項目名稱:stickypunch,代碼行數:50,代碼來源:JettyService.java

示例9: start

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
@Override
public void start() {

	SelectChannelConnector wsConnector = new SelectChannelConnector();
	wsConnector.setHost(listenAddress);
	wsConnector.setPort(listenPort);
	wsConnector.setName("webSocket");
	wsConnector.setThreadPool(new QueuedThreadPool(10));
	server.setConnectors(new Connector[] { wsConnector });
	server.setHandler(new WebSocketHandler() {

		@Override
		public WebSocket doWebSocketConnect(HttpServletRequest request,
				String protocol) {

			log.debug("Request path:" + request.getRequestURI());
			String beanName = request.getRequestURI().replaceFirst("\\/",
					"");
			final WebsocketHandler handler = applicationContext.getBean(
					beanName, WebsocketHandler.class);

			return new WebSocket.OnTextMessage() {

				@Override
				public void onOpen(Connection connection) {
					connection.setMaxIdleTime(3600000);
					handler.setConnection(connection);
					handler.start();
				}

				@Override
				public void onClose(int code, String message) {
					handler.stop();
					log.info("Connection closed.");
				}

				@Override
				public void onMessage(String data) {
					handler.postMessage(data);
				}
			};
		}
	});

	serverThread.execute(new Runnable() {

		@Override
		public void run() {
			try {
				server.start();
				server.join();
			} catch (Exception e) {
				log.warn(e.getMessage(), e);
			}
		}
	});
}
 
開發者ID:3pillarlabs,項目名稱:spring-integration-aws,代碼行數:58,代碼來源:WebSocketListener.java

示例10: run

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public void run() {
    Runtime.getRuntime().addShutdownHook(new ShutdownHook());
    final AppConfig config = AppConfig.getInstance();

    final int listenerthreads = config.getInt("server.listenerthreads", 2);
    final org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server();
    final SelectChannelConnector connector = new SelectChannelConnector();
    final QueuedThreadPool qtp = new QueuedThreadPool();
    qtp.setName("JettyWorkerPool");
    qtp.setMinThreads(5);
    qtp.setMaxThreads(config.getInt("server.worker", 20));
    connector.setThreadPool(qtp);
    connector.setHost(config.getString("server.bind", "0.0.0.0"));
    connector.setPort(config.getInt("server.port", 8080));
    connector.setMaxIdleTime(120000);
    connector.setLowResourcesMaxIdleTime(60000);
    connector.setLowResourcesConnections(20000);
    connector.setAcceptQueueSize(5000);
    connector.setName("pushrouter");

    server.setConnectors(new Connector[]{(Connector) connector});

    final ServletContextHandler schandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
    schandler.setContextPath("/");

    final ServletHolder cholder = schandler.addServlet("net.zyclonite.pushrouter.StreamServlet", "/stream/*");
    cholder.setInitParameter("listenerthreads", String.valueOf(listenerthreads));
    cholder.setAsyncSupported(true);

    final RequestLogHandler requestLogHandler = new RequestLogHandler();
    if (config.getBoolean("server.accesslogs", false)) {
        final NCSARequestLog requestLog = new NCSARequestLog(config.getString("server.logdir", "./") + "web-yyyy_mm_dd.request.log");
        requestLog.setRetainDays(90);
        requestLog.setAppend(true);
        requestLog.setExtended(false);
        requestLog.setLogTimeZone("GMT");
        requestLogHandler.setRequestLog(requestLog);
    }

    final HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[]{schandler, new DefaultHandler(), requestLogHandler});
    server.setHandler(handlers);

    try {
        server.start();
        LOG.info("PushRouter started");
    } catch (Exception ex) {
        LOG.error("PushRouter could not be started");
    }
}
 
開發者ID:zyclonite,項目名稱:pushrouter,代碼行數:51,代碼來源:Server.java


注:本文中的org.eclipse.jetty.server.nio.SelectChannelConnector.setThreadPool方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。