Refine search
private void internalInit() { if (mThreadPoolExecutor != null && !mThreadPoolExecutor.isShutdown()) { mThreadPoolExecutor.shutdownNow(); } mThreadPoolExecutor = new ThreadPoolExecutor( CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_SECONDS, TimeUnit.SECONDS, sPoolWorkQueue, sThreadFactory); mThreadPoolExecutor.allowCoreThreadTimeOut(true); }
private ThreadPoolExecutor createExecutor() { ThreadPoolExecutor exec = new ThreadPoolExecutor(0, 2, 30, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), factory); exec.allowCoreThreadTimeOut(true); return exec; } }
executor = new ThreadPoolExecutor( this.corePoolSize, this.maxPoolSize, this.keepAliveSeconds, TimeUnit.SECONDS, queue, threadFactory, rejectedExecutionHandler) { executor = new ThreadPoolExecutor( this.corePoolSize, this.maxPoolSize, this.keepAliveSeconds, TimeUnit.SECONDS, queue, threadFactory, rejectedExecutionHandler); executor.allowCoreThreadTimeOut(true);
/** * Create a new CachedThreadPool with a bounded number as the maximum * thread size in the pool. * * @param maxCachedThread the maximum thread could be created in the pool * @param timeout the maximum time to wait * @param unit the time unit of the timeout argument * @param threadFactory the factory to use when creating new threads * @return threadPoolExecutor the cachedThreadPool with a bounded number * as the maximum thread size in the pool. */ public static ThreadPoolExecutor getBoundedCachedThreadPool( int maxCachedThread, long timeout, TimeUnit unit, ThreadFactory threadFactory) { ThreadPoolExecutor boundedCachedThreadPool = new ThreadPoolExecutor(maxCachedThread, maxCachedThread, timeout, unit, new LinkedBlockingQueue<>(), threadFactory); // allow the core pool threads timeout and terminate boundedCachedThreadPool.allowCoreThreadTimeOut(true); return boundedCachedThreadPool; }
/** * Creates a new instance of {@link AsyncUfsAbsentPathCache}. * * @param mountTable the mount table * @param numThreads the maximum number of threads for the async thread pool */ public AsyncUfsAbsentPathCache(MountTable mountTable, int numThreads) { mMountTable = mountTable; mCurrentPaths = new ConcurrentHashMap<>(8, 0.95f, 8); mCache = CacheBuilder.newBuilder().maximumSize(MAX_PATHS).build(); mThreads = numThreads; mPool = new ThreadPoolExecutor(mThreads, mThreads, THREAD_KEEP_ALIVE_SECONDS, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), ThreadFactoryUtils.build("UFS-Absent-Path-Cache-%d", true)); mPool.allowCoreThreadTimeOut(true); }
/** * Creates a thread pool that creates new threads as needed up to * a maximum number of threads, but will reuse previously constructed * threads when they are available. * * @param minThreads the minimum number of threads to have at a given time * @param maxThreads the maximum number of threads to have at a given time * @param queueSize the size of the queue before new submissions are rejected * @return the newly created thread pool */ public static ExecutorService newBoundedCachedThreadPool(int minThreads, int maxThreads, int queueSize) { ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( minThreads, maxThreads, 60L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(queueSize)); threadPoolExecutor.allowCoreThreadTimeOut(true); return threadPoolExecutor; }
public static ExecutorService newFixedThreadPoolWithFeedSize(String threadName, int poolSize, int feedSize) { LinkedBlockingQueue<Runnable> feed = new LinkedBlockingQueue<>(feedSize); RejectedExecutionHandler rejectionHandler = new ThreadPoolExecutor.CallerRunsPolicy(); ThreadFactory threadFactory = new LoggingThreadFactory(threadName); ThreadPoolExecutor executor = new ThreadPoolExecutor(poolSize, poolSize, 10, SECONDS, feed, threadFactory, rejectionHandler); executor.allowCoreThreadTimeOut(true); return executor; }
private ThreadPoolExecutor createExecutor() { ThreadPoolExecutor exec = new ThreadPoolExecutor(0, Integer.MAX_VALUE, getDefaultKeepAliveTime(), TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), factory); exec.allowCoreThreadTimeOut(true); return exec; }
private static ThreadPoolExecutor createDelegate() { ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( MAX_THREAD_COUNT, MAX_THREAD_COUNT, KEEP_ALIVE_TIME_IN_MINUTES, MINUTES, new LinkedBlockingQueue<>(UNLIMITED_QUEUE), new ThreadFactoryBuilder() .setDaemon(false) .setNameFormat("SQ_async-%d") .setUncaughtExceptionHandler(((t, e) -> LOG.error("Thread " + t + " failed unexpectedly", e))) .build()); threadPoolExecutor.allowCoreThreadTimeOut(true); return threadPoolExecutor; }
this.connectionExecutor = new ThreadPoolExecutor(3, quorumCnxnThreadsSize, 60, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), daemonThFactory); this.connectionExecutor.allowCoreThreadTimeOut(true);
public AsyncNoBundler() { thread_pool=new ThreadPoolExecutor(0, max_threads, 30000, TimeUnit.MICROSECONDS, new SynchronousQueue<>(), new DefaultThreadFactory("async-bundler", true, true), new ThreadPoolExecutor.CallerRunsPolicy()); thread_pool.allowCoreThreadTimeOut(true); }
private void createBatchPool(Configuration conf) { // Use the same config for keep alive as in ConnectionImplementation.getBatchPool(); int maxThreads = conf.getInt("hbase.multihconnection.threads.max", 256); if (maxThreads == 0) { maxThreads = Runtime.getRuntime().availableProcessors() * 8; } long keepAliveTime = conf.getLong("hbase.multihconnection.threads.keepalivetime", 60); LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(maxThreads * conf.getInt(HConstants.HBASE_CLIENT_MAX_TOTAL_TASKS, HConstants.DEFAULT_HBASE_CLIENT_MAX_TOTAL_TASKS)); ThreadPoolExecutor tpe = new ThreadPoolExecutor(maxThreads, maxThreads, keepAliveTime, TimeUnit.SECONDS, workQueue, Threads.newDaemonThreadFactory("MultiHConnection" + "-shared-")); tpe.allowCoreThreadTimeOut(true); this.batchPool = tpe; }
FlushTableSubprocedurePool(String name, Configuration conf, Abortable abortable) { this.abortable = abortable; // configure the executor service long keepAlive = conf.getLong( RegionServerFlushTableProcedureManager.FLUSH_TIMEOUT_MILLIS_KEY, RegionServerFlushTableProcedureManager.FLUSH_TIMEOUT_MILLIS_DEFAULT); int threads = conf.getInt(CONCURENT_FLUSH_TASKS_KEY, DEFAULT_CONCURRENT_FLUSH_TASKS); this.name = name; executor = new ThreadPoolExecutor(threads, threads, keepAlive, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new DaemonThreadFactory("rs(" + name + ")-flush-proc-pool")); executor.allowCoreThreadTimeOut(true); taskPool = new ExecutorCompletionService<>(executor); }
SnapshotSubprocedurePool(String name, Configuration conf, Abortable abortable) { this.abortable = abortable; // configure the executor service long keepAlive = conf.getLong( RegionServerSnapshotManager.SNAPSHOT_TIMEOUT_MILLIS_KEY, RegionServerSnapshotManager.SNAPSHOT_TIMEOUT_MILLIS_DEFAULT); int threads = conf.getInt(CONCURENT_SNAPSHOT_TASKS_KEY, DEFAULT_CONCURRENT_SNAPSHOT_TASKS); this.name = name; executor = new ThreadPoolExecutor(threads, threads, keepAlive, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new DaemonThreadFactory("rs(" + name + ")-snapshot-pool")); executor.allowCoreThreadTimeOut(true); taskPool = new ExecutorCompletionService<>(executor); }
GroupCacheLoader() { if (reloadGroupsInBackground) { ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat("Group-Cache-Reload") .setDaemon(true) .build(); // With coreThreadCount == maxThreadCount we effectively // create a fixed size thread pool. As allowCoreThreadTimeOut // has been set, all threads will die after 60 seconds of non use ThreadPoolExecutor parentExecutor = new ThreadPoolExecutor( reloadGroupsThreadCount, reloadGroupsThreadCount, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), threadFactory); parentExecutor.allowCoreThreadTimeOut(true); executorService = MoreExecutors.listeningDecorator(parentExecutor); } }
public static ThreadPoolExecutor newDefaultThreadPool(int nThreads, LinkedBlockingQueue<Runnable> queue, String prefix) { final ThreadPoolExecutor executor = new ThreadPoolExecutor(nThreads, nThreads, DEFAULT_IDLE_SECOND, TimeUnit.SECONDS, queue, new FileDownloadThreadFactory(prefix)); executor.allowCoreThreadTimeOut(true); return executor; }
ThreadPoolExecutor executor = new ThreadPoolExecutor( CORE_THREADS_PER_VOLUME, MAXIMUM_THREADS_PER_VOLUME, THREADS_KEEP_ALIVE_SECONDS, TimeUnit.SECONDS, executor.allowCoreThreadTimeOut(true); executors.put(volumes[v], executor);
executor = new ThreadPoolExecutor( this.corePoolSize, this.maxPoolSize, this.keepAliveSeconds, TimeUnit.SECONDS, queue, threadFactory, rejectedExecutionHandler) { executor = new ThreadPoolExecutor( this.corePoolSize, this.maxPoolSize, this.keepAliveSeconds, TimeUnit.SECONDS, queue, threadFactory, rejectedExecutionHandler); executor.allowCoreThreadTimeOut(true);
@InterfaceAudience.Private public static ThreadPoolExecutor getDefaultExecutor(Configuration conf) { int maxThreads = conf.getInt("hbase.htable.threads.max", Integer.MAX_VALUE); if (maxThreads == 0) { maxThreads = 1; // is there a better default? } int corePoolSize = conf.getInt("hbase.htable.threads.coresize", 1); long keepAliveTime = conf.getLong("hbase.htable.threads.keepalivetime", 60); // Using the "direct handoff" approach, new threads will only be created // if it is necessary and will grow unbounded. This could be bad but in HCM // we only create as many Runnables as there are region servers. It means // it also scales when new region servers are added. ThreadPoolExecutor pool = new ThreadPoolExecutor(corePoolSize, maxThreads, keepAliveTime, TimeUnit.SECONDS, new SynchronousQueue<>(), Threads.newDaemonThreadFactory("htable")); pool.allowCoreThreadTimeOut(true); return pool; }
private static ThreadPoolExecutor getThreadPoolExecutor() { int corePoolSize = 3; int maxPoolSize = Integer.MAX_VALUE; int keepAliveTime = 3; ThreadPoolExecutor executor = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new NamedThreadFactory(ThreadPool.class.getSimpleName())); executor.allowCoreThreadTimeOut(true); return executor; }