protected void initAsyncJobExecutionThreadPool() { if (threadPoolQueue == null) { log.info("Creating thread pool queue of size {}", queueSize); threadPoolQueue = new ArrayBlockingQueue<Runnable>(queueSize); } if (executorService == null) { log.info("Creating executor service with corePoolSize {}, maxPoolSize {} and keepAliveTime {}", corePoolSize, maxPoolSize, keepAliveTime); BasicThreadFactory threadFactory = new BasicThreadFactory.Builder().namingPattern("activiti-async-job-executor-thread-%d").build(); executorService = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.MILLISECONDS, threadPoolQueue, threadFactory); } }
public ExecutorServiceObject(final String namingPattern, final int threadSize) { workQueue = new LinkedBlockingQueue<>(); threadPoolExecutor = new ThreadPoolExecutor(threadSize, threadSize, 5L, TimeUnit.MINUTES, workQueue, new BasicThreadFactory.Builder().namingPattern(Joiner.on("-").join(namingPattern, "%s")).build()); threadPoolExecutor.allowCoreThreadTimeOut(true); }
// Create a factory that produces daemon threads with a naming pattern and // a priority BasicThreadFactory factory = new BasicThreadFactory.Builder() .namingPattern("workerthread-%d") .daemon(true) .priority(Thread.MAX_PRIORITY) .build(); // Create an executor service for single-threaded execution ExecutorService exec = Executors.newSingleThreadExecutor(factory);
@PostConstruct public void start() { LinkedBlockingQueue<Runnable> executorQueue = new LinkedBlockingQueue<>(1000); BasicThreadFactory threadFactory = new BasicThreadFactory.Builder() .namingPattern("SubscriptionTriggering-%d") .daemon(false)
public LinkedBlockingQueueSubscribableChannel(BlockingQueue<Runnable> theQueue, String theThreadNamingPattern) { ThreadFactory threadFactory = new BasicThreadFactory.Builder() .namingPattern(theThreadNamingPattern) .daemon(false) .priority(Thread.NORM_PRIORITY) .build(); RejectedExecutionHandler rejectedExecutionHandler = (theRunnable, theExecutor) -> { ourLog.info("Note: Executor queue is full ({} elements), waiting for a slot to become available!", theQueue.size()); StopWatch sw = new StopWatch(); try { theQueue.put(theRunnable); } catch (InterruptedException theE) { throw new RejectedExecutionException("Task " + theRunnable.toString() + " rejected from " + theE.toString()); } ourLog.info("Slot become available after {}ms", sw.getMillis()); }; ThreadPoolExecutor executor = new ThreadPoolExecutor( 1, SubscriptionConstants.EXECUTOR_THREAD_COUNT, 0L, TimeUnit.MILLISECONDS, theQueue, threadFactory, rejectedExecutionHandler); myQueue = theQueue; mySubscribableChannel = new ExecutorSubscribableChannel(executor); }
BasicThreadFactory threadFactory = new BasicThreadFactory.Builder() .namingPattern("worker-" + "-%d") .daemon(false)
public GremlinExecutor create() { final BasicThreadFactory threadFactory = new BasicThreadFactory.Builder().namingPattern("gremlin-executor-default-%d").build(); final AtomicBoolean poolCreatedByBuilder = new AtomicBoolean(); final AtomicBoolean suppliedExecutor = new AtomicBoolean(true); final AtomicBoolean suppliedScheduledExecutor = new AtomicBoolean(true); final ExecutorService es = Optional.ofNullable(executorService).orElseGet(() -> { poolCreatedByBuilder.set(true); suppliedExecutor.set(false); return Executors.newScheduledThreadPool(4, threadFactory); }); executorService = es; final ScheduledExecutorService ses = Optional.ofNullable(scheduledExecutorService).orElseGet(() -> { // if the pool is created by the builder and we need another just re-use it, otherwise create // a new one of those guys suppliedScheduledExecutor.set(false); return (poolCreatedByBuilder.get()) ? (ScheduledExecutorService) es : Executors.newScheduledThreadPool(4, threadFactory); }); scheduledExecutorService = ses; return new GremlinExecutor(this, suppliedExecutor.get(), suppliedScheduledExecutor.get()); } }
/** * Creates a default executor service. This method is called if no executor * has been passed to the constructor. * * @return the default executor service */ private static ScheduledExecutorService createDefaultExecutorService() { final ThreadFactory factory = new BasicThreadFactory.Builder() .namingPattern("ReloadingTrigger-%s").daemon(true) .build(); return Executors.newScheduledThreadPool(1, factory); } }
public AbstractClient(final String threadPattern) { final BasicThreadFactory threadFactory = new BasicThreadFactory.Builder().namingPattern(threadPattern).build(); group = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors(), threadFactory); }
public static ThreadFactory create(final String pattern) { return new BasicThreadFactory.Builder().namingPattern(SERVER_THREAD_PREFIX + pattern).build(); } }
public Factory(final int nioPoolSize) { final BasicThreadFactory threadFactory = new BasicThreadFactory.Builder().namingPattern("gremlin-driver-loop-%d").build(); group = new NioEventLoopGroup(nioPoolSize, threadFactory); }
ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor( pullMsgThreadSize, new BasicThreadFactory.Builder() .namingPattern( "PullMessageTask-" + messageType + "-thread-pool-%d")
ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor( pullMsgThreadSize, new BasicThreadFactory.Builder() .namingPattern( "PullMessageTask-" + messageType + "-thread-pool-%d")
ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor( pullMsgThreadSize, new BasicThreadFactory.Builder() .namingPattern( "PullMessageTask-" + messageType + "-thread-pool-%d")
@VisibleForTesting public static void scheduleClearDanglingScratchDir(HiveConf hiveConf, int initialWaitInSec) { if (hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_CLEAR_DANGLING_SCRATCH_DIR)) { ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor( new BasicThreadFactory.Builder() .namingPattern("cleardanglingscratchdir-%d") .daemon(true) .build()); executor.scheduleAtFixedRate(new ClearDanglingScratchDir(false, false, false, HiveConf.getVar(hiveConf, HiveConf.ConfVars.SCRATCHDIR), hiveConf), initialWaitInSec, HiveConf.getTimeVar(hiveConf, ConfVars.HIVE_SERVER2_CLEAR_DANGLING_SCRATCH_DIR_INTERVAL, TimeUnit.SECONDS), TimeUnit.SECONDS); } }
static void scheduleCMClearer(Configuration conf) { if (MetastoreConf.getBoolVar(conf, ConfVars.REPLCMENABLED)) { ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor( new BasicThreadFactory.Builder() .namingPattern("cmclearer-%d") .daemon(true) .build()); executor.scheduleAtFixedRate(new CMClearer(MetastoreConf.getVar(conf, ConfVars.REPLCMDIR), MetastoreConf.getTimeVar(conf, ConfVars.REPLCMRETIAN, TimeUnit.SECONDS), conf), 0, MetastoreConf.getTimeVar(conf, ConfVars.REPLCMINTERVAL, TimeUnit.SECONDS), TimeUnit.SECONDS); } }
MetastoreStatsConnector(int cacheSize, int batchSize, StatsSource ss) { this.ss = ss; executor = Executors.newSingleThreadExecutor( new BasicThreadFactory.Builder() .namingPattern("Metastore-RuntimeStats-Loader-%d") .daemon(true) .build()); executor.submit(new RuntimeStatsLoader(cacheSize, batchSize)); }
@Inject public FilterFileManager(FilterFileManagerConfig config, FilterLoader filterLoader) { this.config = config; this.filterLoader = filterLoader; BasicThreadFactory threadFactory = new BasicThreadFactory.Builder() .namingPattern("FilterFileManager_ProcessFiles-%d") .build(); this.processFilesService = Executors.newFixedThreadPool(FILE_PROCESSOR_THREADS.get(), threadFactory); }
@Inject public FilterFileManager(FilterFileManagerConfig config, FilterLoader filterLoader) { this.config = config; this.filterLoader = filterLoader; BasicThreadFactory threadFactory = new BasicThreadFactory.Builder() .namingPattern("FilterFileManager_ProcessFiles-%d") .build(); this.processFilesService = Executors.newFixedThreadPool(FILE_PROCESSOR_THREADS.get(), threadFactory); }
@Before public void setUp() throws Exception { builder = new BasicThreadFactory.Builder(); }