• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ExecutorThreadPool类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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);
			if (ip!=null && ip.trim().length()>0) {
				connector.setHost(ip);	// The network interface this connector binds to as an IP address or a hostname.  If null or 0.0.0.0, then bind to all interfaces.
			}
			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 server
				server.start();
				logger.info(">>>>>>>>>>> xxl-job jetty server start success at port:{}.", port);

				// Start Registry-Server
				ExecutorRegistryThread.getInstance().start(port, ip, appName);

				// Start Callback-Server
				TriggerCallbackThread.getInstance().start();

				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.getMessage(), e);
			} finally {
				//destroy();
			}
		}
	});
	thread.setDaemon(true);	// daemon, service jvm, user thread leave >>> daemon leave >>> jvm leave
	thread.start();
}
 
开发者ID:mmwhd,项目名称:stage-job,代码行数:45,代码来源:JettyServer.java


示例17: createThreadPool

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
private ThreadPool createThreadPool() {
    return new ExecutorThreadPool(SystemRuntime.getRuntime().getExecutorService());
}
 
开发者ID:labsai,项目名称:EDDI,代码行数:4,代码来源:ServerRuntime.java


示例18: MesosSchedulerServerImpl

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
MesosSchedulerServerImpl(MesosSchedulerServerBuilder builder, Scheduler scheduler, MesosMasterClient master, FrameworkInfo frameworkInfo) {
  this.credential = requireNonNull(builder.getCredential());
  this.serverExecutor = requireNonNull(builder.getServerExecutor());
  this.serverPort = builder.getServerPort();
  this.scheduler = requireNonNull(scheduler);
  this.master = requireNonNull(master);
  this.frameworkInfo = requireNonNull(frameworkInfo);

  Server schedulerProcessServer = new Server(new ExecutorThreadPool(builder.getServerExecutor()));

  org.eclipse.jetty.util.thread.Scheduler taskScheduler =
      new ScheduledExecutorScheduler("Jetty-Scheduler", true);

  // This is necessary for the session manager and connection timeout logic to use non-daemon
  // threads.
  schedulerProcessServer.addBean(taskScheduler);

  ServerConnector connector = new ServerConnector(schedulerProcessServer);

  connector.setHost(requireNonNull(builder.getServerHostAddress()));
  connector.setPort(serverPort);
  schedulerProcessServer.addConnector(connector);

  ServletContextHandler context = new ServletContextHandler();
  context.setContextPath("/");
  context.addServlet(new ServletHolder(
      new SchedulerServlet(scheduler, serverExecutor, master)),
      "/scheduler(1)/*");

  authenticateeServlet = new AuthenticateeServlet(
      PID.fromString("[email protected]:8080"),
      credential,
      new LibprocessClientBuilder()
          .setFromPort(8080)
          .setFromId("authenticatee")
          .build());
  context.addServlet(new ServletHolder(authenticateeServlet), "/authenticatee/*");

  schedulerProcessServer.setHandler(context);
  this.masterServer = schedulerProcessServer;
}
 
开发者ID:kevints,项目名称:mesos-framework-api,代码行数:42,代码来源:MesosSchedulerServerImpl.java


示例19: init

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
@Override
public void init() throws Exception {
    super.init();

    if (client == null) {
        client = new HttpClient(new SslContextFactory());
        client.setExecutor(new ExecutorThreadPool(threadPool));
        // configure timeout if set
        if (connectTimeout != -1) {
            client.setConnectTimeout(connectTimeout);
        }
        if (idleTimeout != -1) {
            client.setIdleTimeout(idleTimeout);
        }
        client.setMaxConnectionsPerDestination(maxConnectionsPerDestination);
        client.setMaxRequestsQueuedPerDestination(maxRequestsQueuedPerDestination);

        //Configure SSL - if relevant
        if (transportSSLEnabled) {
            KeyStoreManagement keyStore = KeyStoreManagement.getKeyStoreManagement(httpsKeystoreType, httpsKeystore, httpsKeyPassword);
            if (jmxControl != null && keyStore != null) {
                jmxControl.registerMBean("CoUGAR:name=AsyncHttpClientKeyStore,beanName="+beanName, keyStore);
            }
            KeyStoreManagement trustStore = KeyStoreManagement.getKeyStoreManagement(httpsTruststoreType, httpsTruststore, httpsTrustPassword);
            if (jmxControl != null) {
                jmxControl.registerMBean("CoUGAR:name=AsyncHttpClientTrustStore,beanName="+beanName, trustStore);
            }
            if (trustStore == null) {
                throw new IllegalStateException("This configuration ostensibly supports TLS, yet doesn't provide valid truststore configuration");
            }

            final SslContextFactory sslContextFactory = client.getSslContextFactory();

            com.betfair.cougar.netutil.SslContextFactory factory = new com.betfair.cougar.netutil.SslContextFactory();
            factory.setTrustManagerFactoryKeyStore(trustStore.getKeyStore());
            if (keyStore != null) {
                factory.setKeyManagerFactoryKeyStore(keyStore.getKeyStore());
                factory.setKeyManagerFactoryKeyStorePassword(httpsKeyPassword);
            }
            SSLContext context = factory.newInstance();

            if (hostnameVerificationDisabled) {
                context.getDefaultSSLParameters().setEndpointIdentificationAlgorithm(null);
                LOGGER.warn("CRITICAL SECURITY CHECKS ARE DISABLED: server SSL certificate hostname " +
                        "verification is turned off.");
            }
            else {
                context.getDefaultSSLParameters().setEndpointIdentificationAlgorithm("https");
            }

            sslContextFactory.setSslContext(context);
        }
        client.start();
        clientCreated = true;
    }

    metrics = new JettyTransportMetrics();

    if (jmxControl != null) {
        jmxControl.registerMBean("CoUGAR:name=AsyncHttpClientExecutable,beanName=" + beanName, this);
    }
}
 
开发者ID:betfair,项目名称:cougar,代码行数:63,代码来源:AsyncHttpExecutable.java


示例20: main

import org.eclipse.jetty.util.thread.ExecutorThreadPool; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    Options options = new Options();

    Option option = new Option("p", "port", true, "Port number");
    option.setType(Integer.class);
    option.setRequired(true);
    options.addOption(option);

    option = new Option("d", "stateDir", true, "Directory in which lucene data is located");
    option.setType(String.class);
    option.setRequired(true);
    options.addOption(option);

    PosixParser parser = new PosixParser();
    CommandLine commandLine = null;
    try {
        commandLine = parser.parse(options, args);
    } catch (MissingOptionException e) {
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("start-suggestion-server" , options);
        System.exit(1);
    }

    Integer port = new Integer(commandLine.getOptionValue("p"));
    String stateDir = commandLine.getOptionValue("d");

    if (Charset.defaultCharset() != Charset.forName("UTF-8")) {
    System.err.println("file.encoding must be UTF-8.");
        System.exit(1);
    }

    SuggestionIndex suggestionIndex = new SuggestionIndex(stateDir + "/suggestions", stateDir + "/ngram", MIN_SHINGLE_SIZE, MAX_SHINGLE_SIZE, COMMIT_COUNT);

    ExecutorThreadPool pool = new ExecutorThreadPool(50, 200, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1000));
    Server server = new Server(pool);
    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory());
    http.setPort(port);
    server.addConnector(http);

    OutOfMemoryShutdown shutdown = new SuggestionShutdown(server, suggestionIndex);
    registerShutdownHandler(shutdown);

    server.setHandler(new SuggestionHandler(suggestionIndex, shutdown));
    server.start();
    server.join();
}
 
开发者ID:seecr,项目名称:meresco-lucene,代码行数:47,代码来源:SuggestionHttpServer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TList类代码示例发布时间:2022-05-21
下一篇:
Java EncryptedKey类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap