本文整理汇总了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();
}
}
示例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();
}
示例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));
}
}
示例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;
}
示例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");
}
示例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;
}
示例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;
}
示例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>>());
}
}
示例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);
}
示例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);
}
示例11: beforeTest
import org.eclipse.jetty.util.BlockingArrayQueue; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
afterPutEvts = new BlockingArrayQueue<>();
afterRmvEvts = new BlockingArrayQueue<>();
}
示例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);
}