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


Java ExecutorThreadPool类代码示例

本文整理汇总了Java中org.eclipse.jetty.util.thread.ExecutorThreadPool的典型用法代码示例。如果您正苦于以下问题:Java ExecutorThreadPool类的具体用法?Java ExecutorThreadPool怎么用?Java ExecutorThreadPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExecutorThreadPool类属于org.eclipse.jetty.util.thread包,在下文中一共展示了ExecutorThreadPool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newExecutorInstance

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public static void newExecutorInstance(String host, int port) {
    TinyHandler tinyHandler = TinyHandler.get();
    JettyHandler jettyHandler = new JettyHandler(tinyHandler);
    Server server = new Server(new ExecutorThreadPool(Executors.newWorkStealingPool()));
    ServerConnector connector = getConnector(server, host, port);
    server = connector.getServer();
    server.setConnectors(new Connector[]{connector});
    server.setHandler(jettyHandler);
    try {
        server.start();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(100);
    }
}
 
开发者ID:WhiteBlue,项目名称:eleme-hackathon,代码行数:17,代码来源:JettyServerFactory.java

示例2: EmbeddedServer

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public EmbeddedServer(int port, String path) throws IOException {
    int queueSize = AtlasConfiguration.WEBSERVER_QUEUE_SIZE.getInt();
    LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<>(queueSize);

    int minThreads = AtlasConfiguration.WEBSERVER_MIN_THREADS.getInt();
    int maxThreads = AtlasConfiguration.WEBSERVER_MAX_THREADS.getInt();
    long keepAliveTime = AtlasConfiguration.WEBSERVER_KEEPALIVE_SECONDS.getLong();
    ExecutorThreadPool pool =
            new ExecutorThreadPool(minThreads, maxThreads, keepAliveTime, TimeUnit.SECONDS, queue);
    server = new Server(pool);

    Connector connector = getConnector(port);
    server.addConnector(connector);

    WebAppContext application = getWebAppContext(path);
    server.setHandler(application);
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:18,代码来源:EmbeddedServer.java

示例3: start

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public void start(final int port) throws Exception {
		thread = new Thread(new Runnable() {
			@Override
			public void run() {

				// The Server
				server = new Server(new ExecutorThreadPool());  // 非阻塞

				// HTTP connector
				ServerConnector connector = new ServerConnector(server);
				connector.setPort(port);
				server.setConnectors(new Connector[]{connector});

				// Set a handler
				HandlerCollection handlerc =new HandlerCollection();
				handlerc.setHandlers(new Handler[]{new JettyServerHandler()});
				server.setHandler(handlerc);

				try {
					// Start the server
					server.start();
					server.join();	// block until thread stopped
				} catch (Exception e) {
					logger.error("", e);
				} finally {
					destroy();
				}
			}
		});
//		thread.setDaemon(true);	// daemon, service jvm, user thread leave >>> daemon leave >>> jvm leave
		thread.start();
	}
 
开发者ID:SnailFastGo,项目名称:netty_op,代码行数:33,代码来源:JettyServer.java

示例4: start

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public void start(final int port, final String ip, final String appName) throws Exception {
	thread = new Thread(new Runnable() {
		@Override
		public void run() {

			// The Server
			server = new Server(new ExecutorThreadPool());  // 非阻塞

			// HTTP connector
			ServerConnector connector = new ServerConnector(server);
			connector.setPort(port);
			server.setConnectors(new Connector[]{connector});

			// Set a handler
			HandlerCollection handlerc =new HandlerCollection();
			handlerc.setHandlers(new Handler[]{new JettyServerHandler()});
			server.setHandler(handlerc);

			try {
				// Start the server
				server.start();
				logger.info(">>>>>>>>>>>> xxl-job jetty server start success at port:{}.", port);
				ExecutorRegistryThread.getInstance().start(port, ip, appName);
				server.join();	// block until thread stopped
				logger.info(">>>>>>>>>>> xxl-rpc server join success, netcon={}, port={}", JettyServer.class.getName(), port);
			} catch (Exception e) {
				logger.error("", e);
			} finally {
				destroy();
			}
		}
	});
	thread.setDaemon(true);	// daemon, service jvm, user thread leave >>> daemon leave >>> jvm leave
	thread.start();
}
 
开发者ID:kevinKaiF,项目名称:xxl-job,代码行数:36,代码来源:JettyServer.java

示例5: setThreadPool

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
@Inject(optional = true)
public void setThreadPool(@Named(JETTY_THREADS_QUEUE_SIZE_PROPERTY) int maxQueueSize,
                            @Named(JETTY_THREADS_MIN_PROPERTY) int minThreads,
                            @Named(JETTY_THREADS_MAX_PROPERTY) int maxThreads,
                            @Named(JETTY_THREADS_KEEP_ALIVE_MS_PROPERTY) long keepAliveMs)
{
	LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(maxQueueSize);
	m_pool = new ExecutorThreadPool(minThreads, maxThreads, keepAliveMs, TimeUnit.MILLISECONDS, queue);
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:10,代码来源:WebServer.java

示例6: ArchosStreamClientImpl

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public ArchosStreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException {
    this.configuration = configuration;

    log.info("Starting Jetty HttpClient...");
    client = new HttpClient();

    // Jetty client needs threads for its internal expiration routines, which we don't need but
    // can't disable, so let's abuse the request executor service for this
    client.setThreadPool(
            new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) {
                @Override
                protected void doStop() throws Exception {
                    // Do nothing, don't shut down the Cling ExecutorService when Jetty stops!
                }
            }
    );

    // These are some safety settings, we should never run into these timeouts as we
    // do our own expiration checking
    client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000);
    client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000);

    client.setMaxRetries(configuration.getRequestRetryCount());

    try {
        client.start();
    } catch (Exception ex) {
        throw new InitializationException(
                "Could not start Jetty HTTP client: " + ex, ex
        );
    }
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:33,代码来源:ArchosStreamClientImpl.java

示例7: ServerManager

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public ServerManager(ServiceConfig config) {
    this.webServiceExecutor = Executors.newFixedThreadPool(32, new DefaultThreadFactory("pulsar-external-web"));
    this.server = new Server(new ExecutorThreadPool(webServiceExecutor));
    this.externalServicePort = config.getWebServicePort();

    List<ServerConnector> connectors = Lists.newArrayList();

    ServerConnector connector = new ServerConnector(server, 1, 1);
    connector.setPort(externalServicePort);
    connectors.add(connector);

    if (config.isTlsEnabled()) {
        SslContextFactory sslCtxFactory = new SslContextFactory();
        try {
            SSLContext sslCtx = SecurityUtility.createSslContext(config.isTlsAllowInsecureConnection(), config.getTlsTrustCertsFilePath(), config.getTlsCertificateFilePath(),
                    config.getTlsKeyFilePath());
            sslCtxFactory.setSslContext(sslCtx);
        } catch (GeneralSecurityException e) {
            throw new RestException(e);
        }

        sslCtxFactory.setWantClientAuth(true);
        ServerConnector tlsConnector = new ServerConnector(server, 1, 1, sslCtxFactory);
        tlsConnector.setPort(config.getWebServicePortTls());
        connectors.add(tlsConnector);
    }

    // Limit number of concurrent HTTP connections to avoid getting out of file descriptors
    connectors.stream().forEach(c -> c.setAcceptQueueSize(1024 / connectors.size()));
    server.setConnectors(connectors.toArray(new ServerConnector[connectors.size()]));
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:32,代码来源:ServerManager.java

示例8: ProxyServer

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public ProxyServer(WebSocketProxyConfiguration config)
        throws PulsarClientException, MalformedURLException, PulsarServerException {
    this.conf = config;
    executorService = Executors.newFixedThreadPool(WebSocketProxyConfiguration.PROXY_SERVER_EXECUTOR_THREADS,
            new DefaultThreadFactory("pulsar-websocket-web"));
    this.server = new Server(new ExecutorThreadPool(executorService));
    List<ServerConnector> connectors = new ArrayList<>();

    ServerConnector connector = new ServerConnector(server);

    connector.setPort(config.getWebServicePort());
    connectors.add(connector);

    // TLS enabled connector
    if (config.isTlsEnabled()) {
        SslContextFactory sslCtxFactory = new SslContextFactory(true);
        try {
            SSLContext sslCtx = SecurityUtility.createSslContext(false, config.getTlsTrustCertsFilePath(), config.getTlsCertificateFilePath(),
                    config.getTlsKeyFilePath());
            sslCtxFactory.setSslContext(sslCtx);

        } catch (GeneralSecurityException e) {
            throw new PulsarServerException(e);
        }

        sslCtxFactory.setWantClientAuth(true);
        ServerConnector tlsConnector = new ServerConnector(server, -1, -1, sslCtxFactory);
        tlsConnector.setPort(config.getWebServicePortTls());
        connectors.add(tlsConnector);

    }

    // Limit number of concurrent HTTP connections to avoid getting out of
    // file descriptors
    connectors.stream().forEach(c -> c.setAcceptQueueSize(1024 / connectors.size()));
    server.setConnectors(connectors.toArray(new ServerConnector[connectors.size()]));
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:38,代码来源:ProxyServer.java

示例9: WebService

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public WebService(PulsarService pulsar) throws PulsarServerException {
    this.handlers = Lists.newArrayList();
    this.pulsar = pulsar;
    this.webServiceExecutor = Executors.newFixedThreadPool(WebService.NUM_ACCEPTORS, new DefaultThreadFactory("pulsar-web"));
    this.server = new Server(new ExecutorThreadPool(webServiceExecutor));
    List<ServerConnector> connectors = new ArrayList<>();

    ServerConnector connector = new PulsarServerConnector(server, 1, 1);
    connector.setPort(pulsar.getConfiguration().getWebServicePort());
    connector.setHost(pulsar.getBindAddress());
    connectors.add(connector);

    if (pulsar.getConfiguration().isTlsEnabled()) {
        SslContextFactory sslCtxFactory = new SslContextFactory();

        try {
            sslCtxFactory.setSslContext(
                    SecurityUtility.createSslContext(
                        pulsar.getConfiguration().isTlsAllowInsecureConnection(),
                        pulsar.getConfiguration().getTlsTrustCertsFilePath(),
                        pulsar.getConfiguration().getTlsCertificateFilePath(),
                        pulsar.getConfiguration().getTlsKeyFilePath()));
        } catch (GeneralSecurityException e) {
            throw new PulsarServerException(e);
        }

        sslCtxFactory.setWantClientAuth(true);
        ServerConnector tlsConnector = new PulsarServerConnector(server, 1, 1, sslCtxFactory);
        tlsConnector.setPort(pulsar.getConfiguration().getWebServicePortTls());
        tlsConnector.setHost(pulsar.getBindAddress());
        connectors.add(tlsConnector);
    }

    // Limit number of concurrent HTTP connections to avoid getting out of file descriptors
    connectors.forEach(c -> c.setAcceptQueueSize(WebService.MAX_CONCURRENT_REQUESTS / connectors.size()));
    server.setConnectors(connectors.toArray(new ServerConnector[connectors.size()]));
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:38,代码来源:WebService.java

示例10: WebServer

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public WebServer(ProxyConfiguration config) {
    this.webServiceExecutor = Executors.newFixedThreadPool(32, new DefaultThreadFactory("pulsar-external-web"));
    this.server = new Server(new ExecutorThreadPool(webServiceExecutor));
    this.externalServicePort = config.getWebServicePort();

    List<ServerConnector> connectors = Lists.newArrayList();

    ServerConnector connector = new ServerConnector(server, 1, 1);
    connector.setPort(externalServicePort);
    connectors.add(connector);

    if (config.isTlsEnabledInProxy()) {
        SslContextFactory sslCtxFactory = new SslContextFactory();
        try {
            SSLContext sslCtx = SecurityUtility.createSslContext(false, null, config.getTlsCertificateFilePath(),
                    config.getTlsKeyFilePath());
            sslCtxFactory.setSslContext(sslCtx);
        } catch (GeneralSecurityException e) {
            throw new RuntimeException(e);
        }

        sslCtxFactory.setWantClientAuth(false);
        ServerConnector tlsConnector = new ServerConnector(server, 1, 1, sslCtxFactory);
        tlsConnector.setPort(config.getWebServicePortTls());
        connectors.add(tlsConnector);
    }

    // Limit number of concurrent HTTP connections to avoid getting out of file descriptors
    connectors.stream().forEach(c -> c.setAcceptQueueSize(1024 / connectors.size()));
    server.setConnectors(connectors.toArray(new ServerConnector[connectors.size()]));
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:32,代码来源:WebServer.java

示例11: start

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
@Override
public void start(final int port, final Serializer serializer) throws Exception {
	Thread thread = new Thread(new Runnable() {
		@Override
		public void run() {
			server = new Server();
			server.setThreadPool(new ExecutorThreadPool(200, 200, 30000));	// 非阻塞
			
			// connector
			SelectChannelConnector connector = new SelectChannelConnector();
			connector.setPort(port);
			connector.setMaxIdleTime(30000);
			server.setConnectors(new Connector[] { connector });
			
			// handler
			HandlerCollection handlerc =new HandlerCollection();  
			handlerc.setHandlers(new Handler[]{new JettyServerHandler(serializer)});
			server.setHandler(handlerc);
			
			try {
				server.start();
				logger.info(">>>>>>>>>>> xxl-rpc server start success, netcon={}, port={}", JettyServer.class.getName(), port);
				server.join();
			} catch (Exception e) {
				logger.error("", e);
			} finally {
				server.destroy();
			}
		}
	});
	thread.setDaemon(true);
	thread.start();
}
 
开发者ID:xuxueli,项目名称:xxl-rpc,代码行数:34,代码来源:JettyServer.java

示例12: setExecutorService

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
@Override
synchronized public void setExecutorService(ExecutorService executorService) {
    if (INSTANCE.server.getThreadPool() == null) {
        INSTANCE.server.setThreadPool(new ExecutorThreadPool(executorService) {
            @Override
            protected void doStop() throws Exception {
                // Do nothing, don't shut down the Cling ExecutorService when Jetty stops!
            }
        });
    }
}
 
开发者ID:kevinshine,项目名称:BeyondUPnP,代码行数:12,代码来源:AndroidJettyServletContainer.java

示例13: StreamClientImpl

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException {
    this.configuration = configuration;

    log.info("Starting Jetty HttpClient...");
    client = new HttpClient();

    // Jetty client needs threads for its internal expiration routines, which we don't need but
    // can't disable, so let's abuse the request executor service for this
    client.setThreadPool(
        new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) {
            @Override
            protected void doStop() throws Exception {
                // Do nothing, don't shut down the Cling ExecutorService when Jetty stops!
            }
        }
    );

    // These are some safety settings, we should never run into these timeouts as we
    // do our own expiration checking
    client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000);
    client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000);

    client.setMaxRetries(configuration.getRequestRetryCount());

    try {
        client.start();
    } catch (Exception ex) {
        throw new InitializationException(
            "Could not start Jetty HTTP client: " + ex, ex
        );
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:33,代码来源:StreamClientImpl.java

示例14: WebServer

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
/**
 * Creates an instance of the web server but does not actually start
 * it. To start it you must call the {@link start} method.
 * 
 * @param config - the mod's core config
 * 
 * @throws IOException thrown when the web socket could not be created and bound
 */
public WebServer(Configuration config) throws IOException
{
	// TODO: set this up to use HTTPS instead when requested
	webServer = new Server(config.get(WEBSERVER_CONFIG_CATEGORY, "port", 1716).getInt());
	webServer.setGracefulShutdown(STOP_WAIT_TIME);
	webServer.setSessionIdManager(new HashSessionIdManager());
	
	int maxConnections = config.get(WEBSERVER_CONFIG_CATEGORY, "max-sessions", 20).getInt();
	if(maxConnections < 2)
	{
		LogHelper.warning("The selected number of minimum connections allowed is too low. Using low default instead.");
		maxConnections = 2;
	}
	
	LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(maxConnections);
	ThreadPool tp = new ExecutorThreadPool(2, maxConnections, 60, TimeUnit.SECONDS, queue);
	webServer.setThreadPool(tp);
	
	handlers = new RegExContextHandlerCollection();
	webServer.setHandler(handlers);
	
	sessionHandler = new SessionHandler();
	sessionHandler.getSessionManager().setSessionIdManager(webServer.getSessionIdManager());
	addHandler("/", sessionHandler);
	
	rootHandler = new RootHttpHandler();
	sessionHandler.setHandler(rootHandler);
	
	resourceHandler = new ResourceHandler();
	addHandler("^/resources/.*$", resourceHandler);
	
	rpcHandler = new JsonRpcHandler();
	addHandler("/rpc/*", rpcHandler);
}
 
开发者ID:cadyyan,项目名称:MCManager,代码行数:43,代码来源:WebServer.java

示例15: JettyServer

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public JettyServer(UG plugin) throws Exception {
    org.eclipse.jetty.util.log.Log.setLog(new JettyNullLogger());
    server = new Server(plugin.getConfig().getInt("APIPort"));
    server.setHandler(new JettyHandler());
    server.setSessionIdManager(new HashSessionIdManager());

    LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<>(MAX_CONNECTIONS);

    ExecutorThreadPool pool = new ExecutorThreadPool(CORE_POOL_SIZE, MAX_CONNECTIONS, KEEP_ALIVE_TIME, TimeUnit.SECONDS, queue);
    server.setThreadPool(pool);
}
 
开发者ID:UltimateGames,项目名称:UltimateGames,代码行数:12,代码来源:JettyServer.java


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