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


Java BlockingArrayQueue类代码示例

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


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

示例1: doStart

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
@Override
protected void doStart() throws Exception
{
    super.doStart();
    _threadsStarted.set(0);

    if (_jobs==null)
    {
        _jobs=_maxQueued>0 ?new ArrayBlockingQueue<Runnable>(_maxQueued)
            :new BlockingArrayQueue<Runnable>(_minThreads,_minThreads);
    }

    int threads=_threadsStarted.get();
    while (isRunning() && threads<_minThreads)
    {
        startThread(threads);
        threads=_threadsStarted.get();
    }
}
 
开发者ID:AdrianBZG,项目名称:PhoneChat,代码行数:20,代码来源:QueuedThreadPool.java

示例2: init

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
@Override
public void init(Properties properties) {
  this.acceptors = Integer.parseInt(properties.getProperty(CONF_INFLUXDB_ACCEPTORS, "4"));
  this.selectors = Integer.parseInt(properties.getProperty(CONF_INFLUXDB_SELECTORS, "2"));
  this.maxThreads = Integer.parseInt(properties.getProperty(CONF_INFLUXDB_JETTY_THREADPOOL, "9"));
  this.idleTimeout = Integer.parseInt(properties.getProperty(CONF_INFLUXDB_IDLE_TIMEOUT, "30000"));
  this.port = Integer.parseInt(properties.getProperty(CONF_INFLUXDB_PORT, "8086"));
  this.host = properties.getProperty(CONF_INFLUXDB_HOST, "127.0.0.1");
  this.token = properties.getProperty(CONF_INFLUXDB_DEFAULT_TOKEN);
  
  try {
    this.url = new URL(properties.getProperty(CONF_INFLUXDB_WARP10_ENDPOINT));
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
  
  if (properties.containsKey(CONF_INFLUXDB_JETTY_MAXQUEUESIZE)) {
    int queuesize = Integer.parseInt(properties.getProperty(CONF_INFLUXDB_JETTY_MAXQUEUESIZE));
    queue = new BlockingArrayQueue<Runnable>(queuesize);
  }
  
  Thread t = new Thread(this);
  t.setDaemon(true);
  t.setName("[InfluxDBWarp10Plugin " + host + ":" + port + "]");
  t.start();
}
 
开发者ID:cityzendata,项目名称:warp10-platform,代码行数:27,代码来源:InfluxDBWarp10Plugin.java

示例3: RestfulServer

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
public RestfulServer(boolean loopback,
    int port,
    String applicationName,
    boolean sslEnabled,
    String keyStoreAlias,
    String keyStorePassword,
    String keyStorePath,
    int maxNumberOfThreads,
    int maxQueuedRequests) {

    this.applicationName = applicationName;
    int maxThreads = maxNumberOfThreads + ACCEPTORS + SELECTORS;
    BlockingArrayQueue<Runnable> queue = new BlockingArrayQueue<>(MIN_THREADS, MIN_THREADS, maxQueuedRequests);
    this.queuedThreadPool = new QueuedThreadPool(maxThreads, MIN_THREADS, IDLE_TIMEOUT, queue);
    this.server = new Server(queuedThreadPool);
    this.handlers = new ContextHandlerCollection();

    server.addEventListener(new MBeanContainer(ManagementFactory.getPlatformMBeanServer()));
    server.setHandler(handlers);

    if (sslEnabled) {
        server.addConnector(makeSslConnector(keyStoreAlias, keyStorePassword, keyStorePath, port));
    } else {
        server.addConnector(makeConnector(loopback, port));
    }
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:27,代码来源:RestfulServer.java

示例4: threadPool

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
private ThreadPool threadPool(Config cfg, ThreadSettingsConfig threadSettingsConfig) {
  int maxThreads = threadSettingsConfig.getHttpdMaxThreads();
  int minThreads = cfg.getInt("httpd", null, "minthreads", 5);
  int maxQueued = cfg.getInt("httpd", null, "maxqueued", 200);
  int idleTimeout = (int) MILLISECONDS.convert(60, SECONDS);
  int maxCapacity = maxQueued == 0 ? Integer.MAX_VALUE : Math.max(minThreads, maxQueued);
  QueuedThreadPool pool =
      new QueuedThreadPool(
          maxThreads,
          minThreads,
          idleTimeout,
          new BlockingArrayQueue<Runnable>(
              minThreads, // capacity,
              minThreads, // growBy,
              maxCapacity // maxCapacity
              ));
  pool.setName("HTTP");
  return pool;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:JettyServer.java

示例5: FreeMarkerService

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
private FreeMarkerService(Builder bulder) {
     maxOutputLength = bulder.getMaxOutputLength();
     maxThreads = bulder.getMaxThreads();
     maxQueueLength = bulder.getMaxQueueLength();
     maxTemplateExecutionTime = bulder.getMaxTemplateExecutionTime();

     int actualMaxQueueLength = maxQueueLength != null
             ? maxQueueLength
             : Math.max(
                     MIN_DEFAULT_MAX_QUEUE_LENGTH,
                     (int) (MAX_DEFAULT_MAX_QUEUE_LENGTH_MILLISECONDS / maxTemplateExecutionTime));
     ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
             maxThreads, maxThreads,
             THREAD_KEEP_ALIVE_TIME, TimeUnit.MILLISECONDS,
             new BlockingArrayQueue<Runnable>(actualMaxQueueLength));
     threadPoolExecutor.allowCoreThreadTimeOut(true);
     templateExecutor = threadPoolExecutor;

     freeMarkerConfig = new Configuration(Configuration.getVersion());
     freeMarkerConfig.setNewBuiltinClassResolver(TemplateClassResolver.ALLOWS_NOTHING_RESOLVER);
     freeMarkerConfig.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
     freeMarkerConfig.setLogTemplateExceptions(false);
     freeMarkerConfig.setAttemptExceptionReporter(new AttemptExceptionReporter() {
@Override
public void report(TemplateException te, Environment env) {
	// Suppress it
}
     });
     freeMarkerConfig.setLocale(AllowedSettingValuesMaps.DEFAULT_LOCALE);
     freeMarkerConfig.setTimeZone(AllowedSettingValuesMaps.DEFAULT_TIME_ZONE);
     freeMarkerConfig.setOutputFormat(AllowedSettingValuesMaps.DEFAULT_OUTPUT_FORMAT);
     freeMarkerConfig.setOutputEncoding("UTF-8");
 }
 
开发者ID:apache,项目名称:incubator-freemarker-online-tester,代码行数:34,代码来源:FreeMarkerService.java

示例6: prepareJettyServerForTestOnly

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
private Server prepareJettyServerForTestOnly() {
    // http://www.eclipse.org/jetty/documentation/current/embedded-examples.html#d0e19863
    QueuedThreadPool threadPool = new QueuedThreadPool(10 /** needed(acceptors=0 + selectors=9 + request=1*/, 1, 2,
            new BlockingArrayQueue<Runnable>(3 /* capacity*/, 2 /* growBy*/, 5 /* maxCapacity*/));
    threadPool.setName("HTTPD");

    Server httpd = new Server(threadPool);
    HttpConfiguration httpConfig = new HttpConfiguration();
    httpConfig.setRequestHeaderSize(128);
    httpConfig.setSendServerVersion(false);
    httpConfig.setSendDateHeader(true);
    ConnectionFactory connectionFactory = new HttpConnectionFactory(httpConfig);

    ServerConnector httpServerConnector =
            new ServerConnector(httpd,
                    null, null, null, 0, 3,
                    connectionFactory);
    // without this line the port number is automatically allocated from an ephemeral port range by
    // the native method
    // Net.localPort()
    httpServerConnector.setPort(9999);

    ServerConnector httpsServerConnector =
            new ServerConnector(httpd,
                    null, null, null, 0, 3,
                    new SslConnectionFactory(new SslContextFactory(), "http/1.1"),
                    connectionFactory);
    httpsServerConnector.setPort(8888);

    httpd.setConnectors(new Connector[]{httpServerConnector, httpsServerConnector});
    return httpd;
}
 
开发者ID:BruceZu,项目名称:KeepTry,代码行数:33,代码来源:SocketTest.java

示例7: createThreadPool

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
protected QueuedThreadPool createThreadPool() {
    BlockingQueue<Runnable> queue = new BlockingArrayQueue<>(minThreads, maxThreads, maxQueuedRequests);
    QueuedThreadPool threadPool = createThreadPool(queue);
    threadPool.setName("bootique-http");

    return threadPool;
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:8,代码来源:ServerFactory.java

示例8: beforeTest

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
    afterPutEvts.clear();
    afterRmvEvts.clear();

    for (int i = 0; i < NODES; i++) {
        afterRmvEvts.put(grid(i).cluster().localNode().id(),
            new BlockingArrayQueue<Cache.Entry<TestKey, TestValue>>());
        afterPutEvts.put(grid(i).cluster().localNode().id(),
            new BlockingArrayQueue<Cache.Entry<TestKey, TestValue>>());
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:13,代码来源:CacheInterceptorPartitionCounterRandomOperationsTest.java

示例9: onAfterPut

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void onAfterPut(Cache.Entry<TestKey, TestValue> e) {
    e.getKey();
    e.getValue();

    UUID id = e.unwrap(Ignite.class).cluster().localNode().id();

    BlockingQueue<Cache.Entry<TestKey, TestValue>> ents = afterPutEvts.get(id);

    if (ents == null) {
        ents = new BlockingArrayQueue<>();

        BlockingQueue<Cache.Entry<TestKey, TestValue>> oldVal = afterPutEvts.putIfAbsent(id, ents);

        ents = oldVal == null ? ents : oldVal;
    }

    ents.add(e);
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:CacheInterceptorPartitionCounterRandomOperationsTest.java

示例10: onAfterRemove

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void onAfterRemove(Cache.Entry<TestKey, TestValue> e) {
    e.getKey();
    e.getValue();

    UUID id = e.unwrap(Ignite.class).cluster().localNode().id();

    BlockingQueue<Cache.Entry<TestKey, TestValue>> ents = afterRmvEvts.get(id);

    if (ents == null) {
        ents = new BlockingArrayQueue<>();

        BlockingQueue<Cache.Entry<TestKey, TestValue>> oldVal = afterRmvEvts.putIfAbsent(id, ents);

        ents = oldVal == null ? ents : oldVal;
    }

    ents.add(e);
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:CacheInterceptorPartitionCounterRandomOperationsTest.java

示例11: beforeTest

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
    afterPutEvts = new BlockingArrayQueue<>();
    afterRmvEvts = new BlockingArrayQueue<>();
}
 
开发者ID:apache,项目名称:ignite,代码行数:6,代码来源:CacheInterceptorPartitionCounterLocalSanityTest.java

示例12: setUp

import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
@Before
public void setUp() {
  BlockingQueue<Runnable> queue = new BlockingArrayQueue<>(8, 1024, 1024);
  queuedThreadPool = new QueuedThreadPool(200, 8, 60000, queue);
  server = new Server(queuedThreadPool);
}
 
开发者ID:prometheus,项目名称:client_java,代码行数:7,代码来源:QueuedThreadPoolStatisticsCollectorTest.java


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