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


Java ThreadPoolConfig.setCorePoolSize方法代码示例

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


在下文中一共展示了ThreadPoolConfig.setCorePoolSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: adjustThreadPool

import org.glassfish.grizzly.threadpool.ThreadPoolConfig; //导入方法依赖的package包/类
private ThreadPoolConfig adjustThreadPool() {
    Integer corePoolSize = 2;
    Integer maxPoolSize = 8;
    ThreadPoolConfig workerPoolConfig = ThreadPoolConfig.defaultConfig();
    workerPoolConfig.setCorePoolSize(corePoolSize);
    workerPoolConfig.setMaxPoolSize(maxPoolSize);

    workerPoolConfig.setPoolName("Worker");
    return workerPoolConfig;
}
 
开发者ID:odiszapc,项目名称:stem,代码行数:11,代码来源:ClusterManagerDaemon.java

示例2: LensServer

import org.glassfish.grizzly.threadpool.ThreadPoolConfig; //导入方法依赖的package包/类
/**
 * Instantiates a new lens server.
 *
 * @param conf the conf
 * @throws IOException Signals that an I/O exception has occurred.
 */
private LensServer(HiveConf conf) throws IOException {
  startServices(conf);
  String baseURI = conf.get(LensConfConstants.SERVER_BASE_URL, LensConfConstants.DEFAULT_SERVER_BASE_URL);
  HttpServer server = GrizzlyHttpServerFactory.createHttpServer(UriBuilder.fromUri(baseURI).build(), getApp(),
    false);

  int corePoolSize = conf.getInt(LensConfConstants.GRIZZLY_CORE_POOL_SIZE,
          LensConfConstants.DEFAULT_GRIZZLY_CORE_POOL_SIZE);
  int maxPoolSize = conf.getInt(LensConfConstants.GRIZZLY_MAX_POOL_SIZE,
          LensConfConstants.DEFAULT_GRIZZLY_MAX_POOL_SIZE);

  ThreadPoolConfig config = ThreadPoolConfig.defaultConfig();
  config.setPoolName("lensserver-pool");
  config.setCorePoolSize(corePoolSize);
  config.setMaxPoolSize(maxPoolSize);
  config.setThreadFactory((new ThreadFactoryBuilder()).setNameFormat("grizzly-http-server-%d")
    .setUncaughtExceptionHandler(new JerseyProcessingUncaughtExceptionHandler()).build());

  NetworkListener listener = server.getListeners().iterator().next();
  listener.getTransport().setWorkerThreadPoolConfig(config);
  serverList.add(server);

  WebappContext adminCtx = new WebappContext("admin", "");
  MetricsServiceImpl metricsService = LensServices.get().getService(MetricsService.NAME);
  adminCtx
    .setAttribute("com.codahale.metrics.servlets.MetricsServlet.registry", (metricsService.getMetricRegistry()));
  adminCtx.setAttribute("com.codahale.metrics.servlets.HealthCheckServlet.registry", metricsService.getHealthCheck());
  final ServletRegistration sgMetrics = adminCtx.addServlet("admin", new AdminServlet());
  sgMetrics.addMapping("/admin/*");
  adminCtx.deploy(server);
}
 
开发者ID:apache,项目名称:lens,代码行数:38,代码来源:LensServer.java

示例3: configureWorkerThreads

import org.glassfish.grizzly.threadpool.ThreadPoolConfig; //导入方法依赖的package包/类
/**
 * See https://grizzly.java.net/coreconfig.html
 * See https://grizzly.java.net/bestpractices.html
 */
private void configureWorkerThreads(@NotNull NetworkListener networkListener) {
    //WorkerThreadIOStrategy is the default anyway.
    //networkListener.getTransport().setIOStrategy(WorkerThreadIOStrategy.getInstance());

    ThreadPoolConfig config = ThreadPoolConfig.defaultConfig(); //makes a copy
    int numThreads = Runtime.getRuntime().availableProcessors() * 2;
    //setting core and max to the same number is important!
    config.setCorePoolSize(numThreads);
    config.setMaxPoolSize(numThreads);
    //a queue limit is optional but recommended
    config.setQueueLimit(1000);
    networkListener.getTransport().setWorkerThreadPoolConfig(config);
}
 
开发者ID:optimaize,项目名称:anythingworks,代码行数:18,代码来源:GrizzlyWebServer.java


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