public JiraHomeReplicatorService(final JiraHome jiraHome, final SecondaryJiraHome secondaryHome, final ApplicationProperties applicationProperties, final AttachmentPathManager attachmentPathManager, final AvatarManager avatarManager, final PluginPath pluginPath, final ClusterLockService clusterLockService, final SchedulerService schedulerService) { this(jiraHome, secondaryHome, applicationProperties, attachmentPathManager, avatarManager, pluginPath, clusterLockService, schedulerService, Executors.newFixedThreadPool(REPLICATOR_THREADS, ThreadFactories.namedThreadFactory("JiraHomeReplicatorService"))); }
/** * Get a {@link ThreadFactory} with the required name prefix. The produced * threads are user threads and have normal priority. * * @param name the prefix to use for naming the threads. * @return a configured {@link ThreadFactory} */ public static ThreadFactory namedThreadFactory(@NotNull final String name) { return named(name).build(); }
/** * Schedules the cache cleanup task. */ @EventListener public void onComponentManagerStarted(final ComponentManagerStartedEvent startedEvent) { ScheduledExecutorService e = Executors.newSingleThreadScheduledExecutor(ThreadFactories .named("jira-botocss") .type(DAEMON) .build() ); long cleanupSecs = BotoCssInliner.EXPIRE_SECS / 2; e.scheduleWithFixedDelay(new CacheCleaner(), cleanupSecs, cleanupSecs, SECONDS); executor.set(e); }
@Override public Object getObject() throws Exception { return Executors.newFixedThreadPool(size, ThreadFactories.namedThreadFactory(name)); }
/** * Get a {@link ThreadFactory} with the required name prefix and type (user or * daemon). The produced threads have normal priority. * * @param name the prefix to use for naming the threads. * @param type whether they are User or Daemon threads. * @return a configured {@link ThreadFactory} */ public static ThreadFactory namedThreadFactory(@NotNull final String name, @NotNull final Type type) { return named(name).type(type).build(); }
private static ListeningExecutorService defaultExecutor(String threadPoolName) { return MoreExecutors.listeningDecorator( java.util.concurrent.Executors.newCachedThreadPool( ThreadFactories.namedThreadFactory(threadPoolName) )); }
/** * Get a {@link ThreadFactory} with the required name prefix, type and * priority. * * @param name the prefix to use for naming the threads. * @param type whether they are User or Daemon threads. * @param priority the thread priority, must not be lower than * {@link Thread#MIN_PRIORITY} or greater than {@link Thread#MAX_PRIORITY} * @return a configured {@link ThreadFactory} */ public static ThreadFactory namedThreadFactory(@NotNull final String name, @NotNull final Type type, final int priority) { return named(name).type(type).priority(priority).build(); }
private ExecutorService newSingleThreadedBoundedExecutor() { return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(EVENT_QUEUE_CAPACITY), ThreadFactories.namedThreadFactory("analyticsEventProcessor", ThreadFactories.Type.DAEMON), new RejectedExecutionHandler() { @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { log.warn("Analytics event not be processed (most likely due to too many events in queue for single-threaded event processor)."); } }); }
private static ExecutorService newExecutorService() { return new ThreadPoolExecutor(0, Integer.MAX_VALUE, 10L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), namedThreadFactory("long-running-task", USER)); }
/** * Create a new instance * @param settingsService Service used to get webhook settings * @param httpClientFactory Factory to generate HttpClients * @param securityService securityService * @param sshScmProtocol generates ssh clone URLs * @param httpScmProtocol generates http clone URLs */ public Notifier(SettingsService settingsService, HttpClientFactory httpClientFactory, SecurityService securityService, SshScmProtocol sshScmProtocol, HttpScmProtocol httpScmProtocol) { this.httpClientFactory = httpClientFactory; this.settingsService = settingsService; this.executorService = Executors.newCachedThreadPool(ThreadFactories.namedThreadFactory("JenkinsWebhook", ThreadFactories.Type.DAEMON)); this.securityService = securityService; this.scmProtocol = sshScmProtocol; this.httpScmProtocol = httpScmProtocol; }
private ExecutorService createBoundedExecutorService() { return new ThreadPoolExecutor(threadPoolSize, threadPoolSize, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(queueSize), namedThreadFactory("hipchat-client", DAEMON), // RejectedExecutionHandler implementation that suppresses the exception that // would be thrown in case of a task being rejected and logs a WARN message instead. new RejectedExecutionHandler() { @Override public void rejectedExecution(Runnable task, ThreadPoolExecutor executor) { log.debug("Task '{}' rejected from thread pool executor '{}'.", task.toString(), executor.toString()); } }); }
final ExecutorService pool = Executors.newSingleThreadExecutor(ThreadFactories.namedThreadFactory("Modification Check", ThreadFactories.Type.DAEMON)); pool.execute(new ModificationCheck(logMsg));
.setThreadFactory(ThreadFactories.namedThreadFactory(options.getThreadPrefix() + "-io", ThreadFactories.Type.DAEMON)) .setDefaultIOReactorConfig(reactorConfig) .setConnectionManager(connectionManager)
DefaultConnectingIOReactor reactor = new DefaultConnectingIOReactor( ioReactorConfig, ThreadFactories.namedThreadFactory(options.getThreadPrefix() + "-io", ThreadFactories.Type.DAEMON)); reactor.setExceptionHandler(new IOReactorExceptionHandler()