List of usage examples for java.util.concurrent LinkedBlockingQueue LinkedBlockingQueue
public LinkedBlockingQueue(Collection<? extends E> c)
From source file:org.apache.streams.elasticsearch.example.ElasticsearchPercolateTagger.java
public static void main(String[] args) { LOGGER.info(StreamsConfigurator.config.toString()); Config reindex = StreamsConfigurator.config.getConfig("reindex"); Config source = reindex.getConfig("source"); Config destination = reindex.getConfig("destination"); ElasticsearchReaderConfiguration elasticsearchSourceConfiguration = ElasticsearchConfigurator .detectReaderConfiguration(source); ElasticsearchPersistReader elasticsearchPersistReader = new ElasticsearchPersistReader( elasticsearchSourceConfiguration); ElasticsearchWriterConfiguration elasticsearchDestinationConfiguration = ElasticsearchConfigurator .detectWriterConfiguration(destination); PercolateTagProcessor percolateTagProcessor = new PercolateTagProcessor( elasticsearchDestinationConfiguration); ElasticsearchPersistWriter elasticsearchPersistWriter = new ElasticsearchPersistWriter( elasticsearchDestinationConfiguration); StreamBuilder builder = new LocalStreamBuilder(new LinkedBlockingQueue<StreamsDatum>(1000)); builder.newPerpetualStream(ElasticsearchPersistReader.STREAMS_ID, elasticsearchPersistReader); builder.addStreamsProcessor(PercolateTagProcessor.STREAMS_ID, percolateTagProcessor, 1, ElasticsearchPersistReader.STREAMS_ID); builder.addStreamsPersistWriter(ElasticsearchPersistWriter.STREAMS_ID, elasticsearchPersistWriter, 1, PercolateTagProcessor.STREAMS_ID); builder.start();// w ww . j ava 2 s . c o m }
From source file:org.apache.streams.elasticsearch.example.ElasticsearchScriptTagger.java
public static void main(String[] args) { LOGGER.info(StreamsConfigurator.config.toString()); Config reindex = StreamsConfigurator.config.getConfig("reindex"); Config source = reindex.getConfig("source"); Config destination = reindex.getConfig("destination"); ElasticsearchReaderConfiguration elasticsearchSourceConfiguration = ElasticsearchConfigurator .detectReaderConfiguration(source); ElasticsearchPersistReader elasticsearchPersistReader = new ElasticsearchPersistReader( elasticsearchSourceConfiguration); EnsureTagArrayProcessor ensureTagArrayProcessor = new EnsureTagArrayProcessor(); ElasticsearchWriterConfiguration elasticsearchDestinationConfiguration = ElasticsearchConfigurator .detectWriterConfiguration(destination); ElasticsearchPersistWriter elasticsearchPersistWriter = new ElasticsearchPersistUpdater( elasticsearchDestinationConfiguration); StreamBuilder builder = new LocalStreamBuilder(new LinkedBlockingQueue<StreamsDatum>(1000)); builder.newPerpetualStream(ElasticsearchPersistReader.STREAMS_ID, elasticsearchPersistReader); builder.addStreamsProcessor(EnsureTagArrayProcessor.STREAMS_ID, ensureTagArrayProcessor, 3, ElasticsearchPersistReader.STREAMS_ID); builder.addStreamsPersistWriter(ElasticsearchPersistWriter.STREAMS_ID, elasticsearchPersistWriter, 1, EnsureTagArrayProcessor.STREAMS_ID); builder.start();// w w w .j a v a 2 s .co m }
From source file:Main.java
@Deprecated public static ExecutorService newFixedThreadPool(int nThreads) { ThreadPoolExecutor exec = new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(nThreads)); exec.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); return exec;/*ww w . ja v a 2 s. c o m*/ }
From source file:Main.java
public static <E> BlockingQueue<E> getLinkedBlockingQueue(int capacity) { return new LinkedBlockingQueue<E>(capacity); }
From source file:Main.java
public static <E> BlockingQueue<E> createLinkedBlockingQueue(int capacity) { return new LinkedBlockingQueue<E>(capacity); }
From source file:Main.java
public static ThreadPoolExecutor newThreadPool(int maximumNumOfThreads, String poolName) { BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(CAPACITY); ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(maximumNumOfThreads, maximumNumOfThreads, 1, TimeUnit.SECONDS, workQueue, createFactory(poolName)); threadPoolExecutor.allowCoreThreadTimeOut(true); return threadPoolExecutor; }
From source file:Main.java
public static <E> BlockingQueue<E> getLinkedBlockingQueue(Collection<? extends E> collection) { return new LinkedBlockingQueue<E>(collection); }
From source file:Main.java
/** * @param threadToCpuRatio - for example, assuming you have 2 CPUs and setting a threadToCpuRation to 3, the result will be a pool with 6 working threads. * @return an {@link ExecutorService} with defined amount of worker thread for each CPUm A {@link SynchronousQueue} and a {@link ThreadPoolExecutor.CallerRunsPolicy} *//*ww w . j a v a 2 s . c om*/ public static ExecutorService getQueuedThreadPool(double threadToCpuRatio, int queueCapacity) { int workingThreads = Double.valueOf(NUM_CPU * threadToCpuRatio).intValue(); return new ThreadPoolExecutor(workingThreads, workingThreads, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(queueCapacity), new ThreadPoolExecutor.CallerRunsPolicy()); }
From source file:Main.java
public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue(final Collection<? extends E> c) { return new LinkedBlockingQueue<E>(c); }
From source file:Main.java
public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue(final int initialCapacity) { return new LinkedBlockingQueue<E>(initialCapacity); }