List of usage examples for java.util.concurrent ArrayBlockingQueue ArrayBlockingQueue
public ArrayBlockingQueue(int capacity)
From source file:com.openteach.diamond.service.request.HSFNetworkRequestHandler.java
@Override public void initialize() { super.initialize(); queue = new ArrayBlockingQueue<Runnable>(resourceConfig.getQueueSize()); threadpool = new ThreadPoolExecutor(resourceConfig.getMinThreadCount(), resourceConfig.getMaxThreadCount(), resourceConfig.getKeepAliveTime(), TimeUnit.SECONDS, queue, new CommonThreadFactory("HSF-Request-Handler-Thread", null, true)); }
From source file:de.vandermeer.skb.interfaces.strategies.collections.queue.ArrayBlockingQueueStrategy.java
/** * Returns a new collection for the given collection. * @param capacity the queue's capacity//from w w w. j a v a 2s. co m * @return new collection */ default ArrayBlockingQueue<T> get(int capacity) { return new ArrayBlockingQueue<T>(capacity); }
From source file:org.openvpms.report.openoffice.AbstractOOConnectionPool.java
/** * Constructs a new <tt>AbstractOOConnectionPool</tt>. * * @param capacity the pool capacity//from w ww . jav a2s. c om */ public AbstractOOConnectionPool(int capacity) { connections = new ArrayBlockingQueue<State>(capacity); this.capacity = capacity; }
From source file:com.kurento.kmf.media.ZBarFilterTest.java
@Test public void testCodeFoundEvent() throws InterruptedException { PlayerEndpoint player = pipeline.newPlayerEndpoint(URL_BARCODES).build(); player.connect(zbar);/*w w w .ja va 2 s .c om*/ final BlockingQueue<CodeFoundEvent> events = new ArrayBlockingQueue<CodeFoundEvent>(1); zbar.addCodeFoundListener(new MediaEventListener<CodeFoundEvent>() { @Override public void onEvent(CodeFoundEvent event) { events.add(event); } }); player.play(); Assert.assertNotNull(events.poll(7, TimeUnit.SECONDS)); player.stop(); player.release(); }
From source file:org.apache.hadoop.io.ReadaheadPool.java
private ReadaheadPool() { pool = new ThreadPoolExecutor(POOL_SIZE, MAX_POOL_SIZE, 3L, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(CAPACITY)); pool.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy()); pool.setThreadFactory(//from w w w. j a v a 2 s. c o m new ThreadFactoryBuilder().setDaemon(true).setNameFormat("Readahead Thread #%d").build()); }
From source file:com.pinterest.rocksplicator.controller.WorkerPoolTest.java
@Test public void testAssignSameCluster() throws Exception { Semaphore idleWorkersSemaphore = new Semaphore(0); ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1)); WorkerPool workerPool = new WorkerPool(threadPoolExecutor, idleWorkersSemaphore, new TaskQueue() { });/* www .j a v a 2 s . com*/ Task task = getSleepIncrementTask(); workerPool.assignTask(task); Thread.sleep(2000); Assert.assertEquals(1, SleepIncrementTask.executionCounter.intValue()); workerPool.assignTask(task); Thread.sleep(2000); Assert.assertEquals(2, (int) SleepIncrementTask.executionCounter); Assert.assertEquals(2, idleWorkersSemaphore.availablePermits()); }
From source file:com.xpn.xwiki.stats.impl.xwiki.XWikiStatsStoreService.java
/** * Create new instance of XWikiStatsRegister and init statistics queue. * //from w ww . ja v a 2s.com * @param context the XWiki context. */ public XWikiStatsStoreService(XWikiContext context) { super(XWikiContext.EXECUTIONCONTEXT_KEY, context); long queueSize = context.getWiki().ParamAsLong("stats.queue.size", 200); this.queue = new ArrayBlockingQueue<XWikiStatsStoreItem>((int) queueSize); }
From source file:com.kurento.kmf.media.JackVaderFilterTest.java
/** * Test if a {@link JackVaderFilter} can be created in the KMS. The filter * is pipelined with a {@link PlayerEndpoint}, which feeds video to the * filter. This test depends on the correct behaviour of the player and its * events.//ww w . j a v a 2 s . com * * @throws InterruptedException */ @Test public void testJackVaderFilter() throws InterruptedException { PlayerEndpoint player = pipeline.newPlayerEndpoint(URL_SMALL).build(); player.connect(jackVader); final BlockingQueue<EndOfStreamEvent> events = new ArrayBlockingQueue<EndOfStreamEvent>(1); player.addEndOfStreamListener(new MediaEventListener<EndOfStreamEvent>() { @Override public void onEvent(EndOfStreamEvent event) { events.add(event); } }); player.play(); Assert.assertNotNull(events.poll(10, SECONDS)); player.stop(); player.release(); }
From source file:org.apache.hadoop.raid.IAEncoder.java
public IAEncoder(Configuration conf, int stripeSize, int paritySize) { super(conf, stripeSize, paritySize); threadNum = conf.getInt("hdfs.raid.encoder.threadnum", 2); //data queue, from input thread to encode thread this.q = new ArrayBlockingQueue[threadNum]; for (int i = 0; i < threadNum; i++) q[i] = new ArrayBlockingQueue<ByteBuffer>(1024 / paritySize); //trigger queue, encode to output this.p = new ArrayBlockingQueue[threadNum]; for (int i = 0; i < threadNum; i++) p[i] = new ArrayBlockingQueue<Integer>(100); //trigger queue, input to encode this.fq = new ArrayBlockingQueue[threadNum]; for (int i = 0; i < threadNum; i++) fq[i] = new ArrayBlockingQueue<byte[][]>(2); //encode thread IAMigrationEncoder[] encoder = new IAMigrationEncoder[threadNum]; Thread[] es = new Thread[threadNum]; for (int i = 0; i < threadNum; i++) { encoder[i] = new IAMigrationEncoder(i); es[i] = new Thread(encoder[i]); es[i].start();//from w ww. j ava 2 s . c o m } LOG.info("IAEncoder 10/9/12 StripeSize: " + stripeSize + " ParitySize: " + paritySize); mcount = 0; }
From source file:org.apache.hadoop.raid.PMEncoder.java
public PMEncoder(Configuration conf, int stripeSize, int paritySize) { super(conf, stripeSize, paritySize); threadNum = conf.getInt("hdfs.raid.encoder.threadnum", 2); //data queue, from input thread to encode thread this.q = new ArrayBlockingQueue[threadNum]; for (int i = 0; i < threadNum; i++) q[i] = new ArrayBlockingQueue<ByteBuffer>(1024 / paritySize); //trigger queue, encode to output this.p = new ArrayBlockingQueue[threadNum]; for (int i = 0; i < threadNum; i++) p[i] = new ArrayBlockingQueue<Integer>(100); //trigger queue, input to encode this.fq = new ArrayBlockingQueue[threadNum]; for (int i = 0; i < threadNum; i++) fq[i] = new ArrayBlockingQueue<byte[][]>(2); //encode thread PMMigrationEncoder[] encoder = new PMMigrationEncoder[threadNum]; Thread[] es = new Thread[threadNum]; for (int i = 0; i < threadNum; i++) { encoder[i] = new PMMigrationEncoder(i); es[i] = new Thread(encoder[i]); es[i].start();//from w w w. ja va 2 s . co m } LOG.info("PMEncoder 10/9/12"); mcount = 0; }