List of usage examples for com.google.common.util.concurrent ThreadFactoryBuilder ThreadFactoryBuilder
public ThreadFactoryBuilder()
From source file:org.apache.hadoop.yarn.server.resourcemanager.amlauncher.ApplicationMasterLauncher.java
@Override protected void serviceInit(Configuration conf) throws Exception { int threadCount = conf.getInt(YarnConfiguration.RM_AMLAUNCHER_THREAD_COUNT, YarnConfiguration.DEFAULT_RM_AMLAUNCHER_THREAD_COUNT); ThreadFactory tf = new ThreadFactoryBuilder().setNameFormat("ApplicationMasterLauncher #%d").build(); launcherPool = new ThreadPoolExecutor(threadCount, threadCount, 1, TimeUnit.HOURS, new LinkedBlockingQueue<Runnable>()); launcherPool.setThreadFactory(tf);/*from ww w.j a v a 2 s .co m*/ Configuration newConf = new YarnConfiguration(conf); newConf.setInt(CommonConfigurationKeysPublic.IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SOCKET_TIMEOUTS_KEY, conf.getInt(YarnConfiguration.RM_NODEMANAGER_CONNECT_RETRIES, YarnConfiguration.DEFAULT_RM_NODEMANAGER_CONNECT_RETRIES)); setConfig(newConf); super.serviceInit(newConf); }
From source file:com.gitblit.transport.ssh.commands.SshCommandFactory.java
public SshCommandFactory(IGitblit gitblit, WorkQueue workQueue) { this.gitblit = gitblit; this.workQueue = workQueue; int threads = gitblit.getSettings().getInteger(Keys.git.sshCommandStartThreads, 2); startExecutor = workQueue.createQueue(threads, "SshCommandStart"); destroyExecutor = Executors.newSingleThreadExecutor( new ThreadFactoryBuilder().setNameFormat("SshCommandDestroy-%s").setDaemon(true).build()); }
From source file:com.facebook.buck.event.listener.NetworkStatsKeeper.java
public NetworkStatsKeeper() { this.bytesDownloaded = new AtomicLong(0); this.bytesDownloadedInLastInterval = new AtomicLong(0); this.artifactDownloaded = new AtomicLong(0); this.artifactDownloadInProgressCount = 0; this.downloadSpeedForLastInterval = 0; this.firstDownloadStartTimestamp = 0; this.lastDownloadFinishedTimeMs = 0; this.totalDownloadTimeMillis = 0; this.currentIntervalDownloadTimeMillis = 0; this.clock = new DefaultClock(); this.scheduler = Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setNameFormat(getClass().getSimpleName() + "-%d").build()); scheduleDownloadSpeedCalculation();/*from w w w.java2 s . c o m*/ }
From source file:br.unb.cic.bionimbuz.services.discovery.DiscoveryService.java
@Inject public DiscoveryService(final CloudMessageService cms) { Preconditions.checkNotNull(cms);// ww w. ja v a 2 s . c o m this.cms = cms; //Duvida porque de duas execuo? LOGGER.info("[DiscoveryService] Called by constructor ..."); schedExecService = Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setDaemon(true).setNameFormat("DiscoveryService-%d").build()); }
From source file:com.dropbox.presto.kafka.KafkaHiveClient.java
@Inject public KafkaHiveClient(KafkaConnectorId connectorId, KafkaClientConfig kafkaClientConfig, KafkaPluginConfig kafkaPluginConfig) { com.facebook.presto.hive.HiveClientConfig hiveClientConfig = new com.facebook.presto.hive.HiveClientConfig(); com.facebook.presto.hive.NamenodeStats nameNodestats = new com.facebook.presto.hive.NamenodeStats(); com.facebook.presto.hive.HdfsConfiguration hdfsConfig = new com.facebook.presto.hive.HdfsConfiguration( hiveClientConfig);//from w ww . j a v a2s.c om com.facebook.presto.hive.HdfsEnvironment hdfsEnv = new com.facebook.presto.hive.HdfsEnvironment(hdfsConfig); com.facebook.presto.hive.DirectoryLister dirListener = new com.facebook.presto.hive.HadoopDirectoryLister(); ExecutorService executorService = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setDaemon(true) .setNameFormat("kafka-hive-" + connectorId + "-%d").build()); com.facebook.presto.hive.HiveConnectorId hiveConnectorId = new com.facebook.presto.hive.HiveConnectorId( connectorId.toString()); com.facebook.presto.hive.HiveCluster hiveCluster = KafkaHiveClient.createHiveCluster(kafkaPluginConfig, kafkaClientConfig); ExecutorService executor = Executors.newFixedThreadPool(kafkaClientConfig.getMaxMetastoreRefreshThreads(), new ThreadFactoryBuilder().setDaemon(true) .setNameFormat("kafka-hive-metastore-" + connectorId + "-%d").build()); com.facebook.presto.hive.CachingHiveMetastore metastore = new com.facebook.presto.hive.CachingHiveMetastore( hiveCluster, executor, hiveClientConfig); hiveClient = new com.facebook.presto.hive.HiveClient(hiveConnectorId, hiveClientConfig, metastore, nameNodestats, hdfsEnv, dirListener, executorService); }
From source file:org.graylog.plugin.filter.dns.DnsResolverFilter.java
@Inject public DnsResolverFilter(@Named("dns_resolver_timeout") Period resolverTimeout, @Named("dns_resolver_run_before_extractors") boolean shouldRunBeforeExtractors, @Named("dns_resolver_enabled") boolean enabled, MetricRegistry metricRegistry) { this.shouldRunBeforeExtractors = shouldRunBeforeExtractors; this.enabled = enabled; timeout = resolverTimeout.toStandardDuration().getMillis(); timeLimiter = SimpleTimeLimiter.create(Executors.newSingleThreadExecutor( new ThreadFactoryBuilder().setDaemon(true).setNameFormat("dns-resolver-thread-%d").build())); this.resolveTime = metricRegistry.timer(name(DnsResolverFilter.class, "resolveTime")); this.resolveTimeouts = metricRegistry.meter(name(DnsResolverFilter.class, "resolveTimeouts")); }
From source file:org.graylog2.inputs.transports.netty.EventLoopGroupFactory.java
private ThreadFactory threadFactory(String name, MetricRegistry metricRegistry) { final String threadFactoryMetricName = MetricRegistry.name(name, "thread-factory"); final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("netty-transport-%d").build(); return new InstrumentedThreadFactory(threadFactory, metricRegistry, threadFactoryMetricName); }
From source file:com.spotify.ffwd.http.HttpOutputPlugin.java
@Override public Module module(final Key<PluginSink> key, final String id) { return new OutputPluginModule(id) { @Provides//from w w w . j av a 2 s .c om @Singleton @Named("http") public ExecutorService threadPool() { return Executors.newCachedThreadPool( new ThreadFactoryBuilder().setNameFormat("ffwd-okhttp-async-%d").build()); } @Provides @Singleton public ILoadBalancer setupRibbonClient(HttpPing httpPing, @Named("searchDomain") final Optional<String> searchDomain) { return discovery.apply(LoadBalancerBuilder.newBuilder(), searchDomain).withPing(httpPing) .buildDynamicServerListLoadBalancer(); } @Override protected void configure() { final Key<HttpPluginSink> sinkKey = Key.get(HttpPluginSink.class, Names.named("httpSink")); bind(sinkKey).to(HttpPluginSink.class).in(Scopes.SINGLETON); install(wrapPluginSink(sinkKey, key)); expose(key); } }; }
From source file:com.baifendian.swordfish.execserver.runner.streaming.StreamingRunnerManager.java
public StreamingRunnerManager(Configuration conf) { streamingDao = DaoFactory.getDaoInstance(StreamingDao.class); int threads = conf.getInt(Constants.EXECUTOR_STREAMING_THREADS, Constants.defaultStreamingThreadNum); ThreadFactory flowThreadFactory = new ThreadFactoryBuilder().setNameFormat("Exec-Server-StreamingRunner") .build();/*from ww w. ja va 2 s. c o m*/ streamingExecutorService = Executors.newFixedThreadPool(threads, flowThreadFactory); }
From source file:org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvokerImpl.java
public TransactionInvokerImpl(DataBroker db) { this.db = db; this.chain = db.createTransactionChain(this); ThreadFactory threadFact = new ThreadFactoryBuilder().setNameFormat("transaction-invoker-impl-%d").build(); executor = Executors.newSingleThreadExecutor(threadFact); executor.submit(this); }