public BatchWriter(EmbeddedSolrServer solr, int batchSize, TaskID tid, int writerThreads, int queueSize) { this.solr = solr; this.writerThreads = writerThreads; this.queueSize = queueSize; taskId = tid; // we need to obtain the settings before the constructor if (writerThreads != 0) { batchPool = new ExecutorUtil.MDCAwareThreadPoolExecutor(writerThreads, writerThreads, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(queueSize), new ThreadPoolExecutor.CallerRunsPolicy()); } else { // single threaded case batchPool = null; } }
long start = System.nanoTime(); int concurrentMerges = options.goLiveThreads; ThreadPoolExecutor executor = new ExecutorUtil.MDCAwareThreadPoolExecutor(concurrentMerges, concurrentMerges, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
long start = System.nanoTime(); int concurrentMerges = options.goLiveThreads; ThreadPoolExecutor executor = new ExecutorUtil.MDCAwareThreadPoolExecutor(concurrentMerges, concurrentMerges, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
/** * See {@link java.util.concurrent.Executors#newSingleThreadExecutor(ThreadFactory)} */ public static ExecutorService newMDCAwareSingleThreadExecutor(ThreadFactory threadFactory) { return new MDCAwareThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory); }
/** * See {@link java.util.concurrent.Executors#newCachedThreadPool(ThreadFactory)} */ public static ExecutorService newMDCAwareCachedThreadPool(ThreadFactory threadFactory) { return new MDCAwareThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), threadFactory); }
/** * See {@link java.util.concurrent.Executors#newCachedThreadPool(ThreadFactory)} */ public static ExecutorService newMDCAwareCachedThreadPool(ThreadFactory threadFactory) { return new MDCAwareThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), threadFactory); }
/** * See {@link java.util.concurrent.Executors#newSingleThreadExecutor(ThreadFactory)} */ public static ExecutorService newMDCAwareSingleThreadExecutor(ThreadFactory threadFactory) { return new MDCAwareThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), threadFactory); }
/** * See {@link java.util.concurrent.Executors#newFixedThreadPool(int, ThreadFactory)} */ public static ExecutorService newMDCAwareFixedThreadPool(int nThreads, ThreadFactory threadFactory) { return new MDCAwareThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory); }
public static ExecutorService newMDCAwareCachedThreadPool(int maxThreads, ThreadFactory threadFactory) { return new MDCAwareThreadPoolExecutor(0, maxThreads, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(maxThreads), threadFactory); }
/** * See {@link java.util.concurrent.Executors#newFixedThreadPool(int, ThreadFactory)} */ public static ExecutorService newMDCAwareFixedThreadPool(int nThreads, ThreadFactory threadFactory) { return new MDCAwareThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory); }