/** * Creates an executor for recurring tasks * * @param groupname a label to identify the threadpool; useful for profiling. * @return instance of {@link ScheduledThreadPoolExecutor} */ public static ScheduledExecutorService newScheduledThreadPool(String groupname) { return new ScheduledThreadPoolExecutor( 1, new SearchThreadFactory( groupname ) ); }
/** * Creates a dynamically scalable threadpool having an upper bound of threads and queue size * which ultimately falls back to a CallerRunsPolicy. * @param threadsMin initial and minimum threadpool size * @param threadsMax maximumx threadpool size * @param groupname used to assign nice names to the threads to help diagnostics and tuning * @param queueSize maximum size of the blocking queue holding the work * @return the new Executor instance */ public static ThreadPoolExecutor newScalableThreadPool(int threadsMin, int threadsMax, String groupname, int queueSize) { return new ThreadPoolExecutor( threadsMin, threadsMax, 30, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>( queueSize ), new SearchThreadFactory( groupname ), new ThreadPoolExecutor.CallerRunsPolicy() ); }
/** * Creates a new fixed size ThreadPoolExecutor * * @param threads the number of threads * @param groupname a label to identify the threadpool; useful for profiling. * @param queueSize the size of the queue to store Runnables when all threads are busy * @return the new ExecutorService */ public static ThreadPoolExecutor newFixedThreadPool(int threads, String groupname, int queueSize) { return new ThreadPoolExecutor( threads, threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>( queueSize ), new SearchThreadFactory( groupname ), new BlockPolicy() ); }
.setMaxConnTotal( MAX_TOTAL_CONNECTION.get( propertySource ) ) .setMaxConnPerRoute( MAX_TOTAL_CONNECTION_PER_ROUTE.get( propertySource ) ) .setThreadFactory( new SearchThreadFactory( "Elasticsearch transport thread" ) ); if ( !hosts.isAnyRequiringSSL() ) {
.setMaxConnTotal( MAX_TOTAL_CONNECTION.get( propertySource ) ) .setMaxConnPerRoute( MAX_TOTAL_CONNECTION_PER_ROUTE.get( propertySource ) ) .setThreadFactory( new SearchThreadFactory( "Elasticsearch transport thread" ) ); if ( !hosts.isAnyRequiringSSL() ) {