List of usage examples for com.google.common.util.concurrent ThreadFactoryBuilder ThreadFactoryBuilder
public ThreadFactoryBuilder()
From source file:talkeeg.common.ipc.StreamSupport.java
@Inject StreamSupport(Bf bf, CryptoService cryptoService, AcquaintedClientsService clientsService, OwnedIdentityCardsService ownedIdentityCardsService, Provider<IpcService> ipcServiceProvider) { this.bf = bf; this.cryptoService = cryptoService; this.clientsService = clientsService; this.ownedIdentityCardsService = ownedIdentityCardsService; this.ipcServiceProvider = ipcServiceProvider; final ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true) .setNameFormat(getClass().getSimpleName() + "-%d").build(); this.scheduledExecutorService = new ScheduledThreadPoolExecutor(1, factory); this.scheduledExecutorService.scheduleWithFixedDelay(watchDog, TIMEOUT, TIMEOUT, TimeUnit.MILLISECONDS); }
From source file:io.tilt.minka.business.impl.CoordinatorImpl.java
public CoordinatorImpl(final Config config, final SpectatorSupplier supplier, final ShardID shardId) { super(config, supplier, shardId); this.shardId = shardId; this.executor = new ScheduledThreadPoolExecutor(MAX_CONCURRENT_THREADS, new ThreadFactoryBuilder().setNameFormat(Config.THREAD_NAME_COORDINATOR_IN_BACKGROUND).build()); executor.setRemoveOnCancelPolicy(true); executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); this.rules = new HashMap<>(); getLockingRules().forEach(rule -> this.rules.put(rule.getAction(), rule)); this.futuresBySynchro = new HashMap<>(); this.runnablesBySynchro = new HashMap<>(); this.callablesBySynchro = new HashMap<>(); this.agentsByAction = new HashMap<>(); }
From source file:com.vmware.photon.controller.common.zookeeper.ZookeeperModule.java
@Provides @Singleton/*w ww. j av a2 s . co m*/ @ZkHostMonitor public ZookeeperHostMonitor getHostMonitor(CuratorFramework zkClient, @ServicePathCacheFactory PathChildrenCacheFactory childrenCacheFactory) throws Exception { ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat("ZkHostMonitorPathChildrenCache" + "-%d").setDaemon(true).build(); ExecutorService executor = Executors.newSingleThreadExecutor(threadFactory); return new ZookeeperHostMonitor(zkClient, childrenCacheFactory, executor); }
From source file:com.pinterest.pinlater.commons.healthcheck.HealthChecker.java
/** * @param name name of the health checker, which is appended to the thread name. *///from w w w .j a v a 2 s . c o m public HealthChecker(String name) { scheduledExecutorService = Executors.newSingleThreadScheduledExecutor( new ThreadFactoryBuilder().setDaemon(true).setNameFormat(name + "-healthchecker-%d").build()); }
From source file:com.yahoo.omid.tso.RetryProcessorImpl.java
@Inject RetryProcessorImpl(MetricsRegistry metrics, CommitTable commitTable, ReplyProcessor replyProc, Panicker panicker) throws InterruptedException, ExecutionException { this.commitTableClient = commitTable.getClient().get(); this.writer = commitTable.getWriter().get(); this.replyProc = replyProc; WaitStrategy strategy = new YieldingWaitStrategy(); retryRing = RingBuffer.<RetryEvent>createSingleProducer(RetryEvent.EVENT_FACTORY, 1 << 12, strategy); SequenceBarrier retrySequenceBarrier = retryRing.newBarrier(); BatchEventProcessor<RetryEvent> retryProcessor = new BatchEventProcessor<RetryEvent>(retryRing, retrySequenceBarrier, this); retryProcessor.setExceptionHandler(new FatalExceptionHandler(panicker)); retryRing.addGatingSequences(retryProcessor.getSequence()); ExecutorService retryExec = Executors .newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("retry-%d").build()); retryExec.submit(retryProcessor);//from ww w.j a v a2s.c o m // Metrics retriesMeter = metrics.meter(name("tso", "retries")); }
From source file:com.viadeo.kasper.core.component.command.gateway.KasperCommandBus.java
public KasperCommandBus(final MetricRegistry metricRegistry) { super(new InstrumentedExecutorService( Executors.newCachedThreadPool( new ThreadFactoryBuilder().setNameFormat(COMMAND_THREAD_NAME + "-%d").build()), checkNotNull(metricRegistry, "metric registry may not be null"), COMMAND_THREAD_NAME)); setUnitOfWorkFactory(new ContextualizedUnitOfWork.Factory()); }
From source file:io.druid.server.coordination.SegmentChangeRequestHistory.java
public SegmentChangeRequestHistory(int maxSize) { this.maxSize = maxSize; this.changes = new CircularBuffer(maxSize); this.waitingFutures = new LinkedHashMap<>(); this.resolveWaitingFuturesRunnable = new Runnable() { @Override/*from w w w . j a v a 2s .c om*/ public void run() { resolveWaitingFutures(); } }; this.singleThreadedExecutor = Executors.newSingleThreadExecutor( new ThreadFactoryBuilder().setDaemon(true).setNameFormat("SegmentChangeRequestHistory").build()); }
From source file:ec.nbdemetra.ui.demo.FakeTsProvider.java
public FakeTsProvider() { super(LoggerFactory.getLogger(FakeTsProvider.class), "Fake", TsAsyncMode.Once); dataBuilder = new DemoUtils.RandomTsCollectionBuilder(); normalData = dataBuilder.build();// w w w . java 2 s . co m DataSource.Builder builder = DataSource.builder(providerName, ""); for (DataType o : DataType.values()) { dataTypeParam.set(builder, o); support.open(builder.build()); } dataTypeParam.set(builder, DataType.UPDATING); final TsMoniker updatingMoniker = toMoniker(builder.build()); this.service = new AbstractExecutionThreadService() { @Override protected Executor executor() { return Executors.newSingleThreadExecutor( new ThreadFactoryBuilder().setDaemon(true).setPriority(Thread.MIN_PRIORITY).build()); } @Override protected void run() throws Exception { while (isRunning()) { queryTsCollection(updatingMoniker, TsInformationType.All); TimeUnit.SECONDS.sleep(3); } } }.startAsync(); }
From source file:org.apache.storm.windowing.WaterMarkEventGenerator.java
/** * Creates a new WatermarkEventGenerator. * @param windowManager The window manager this generator will submit watermark events to * @param intervalMs The generator will check if it should generate a watermark event with this interval * @param eventTsLagMs The max allowed lag behind the last watermark event before an event is considered late * @param inputStreams The input streams this generator is expected to handle *//*from w w w . jav a 2 s. c o m*/ public WaterMarkEventGenerator(WindowManager<T> windowManager, int intervalMs, int eventTsLagMs, Set<GlobalStreamId> inputStreams) { this.windowManager = windowManager; streamToTs = new ConcurrentHashMap<>(); ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("watermark-event-generator-%d") .setDaemon(true).build(); executorService = Executors.newSingleThreadScheduledExecutor(threadFactory); this.interval = intervalMs; this.eventTsLag = eventTsLagMs; this.inputStreams = inputStreams; }
From source file:org.apache.bookkeeper.stream.server.service.RegistrationServiceProvider.java
public RegistrationServiceProvider(ServerConfiguration bkServerConf, DLConfiguration conf, StatsLogger statsLogger) {/*from w w w. j a v a 2 s. c o m*/ super("registration-service-provider", conf, statsLogger); this.zkServers = ZKMetadataDriverBase.resolveZkServers(bkServerConf); this.regPath = ZK_METADATA_ROOT_PATH + "/" + SERVERS_PATH; this.bkZkRetryPolicy = new BoundExponentialBackoffRetryPolicy(bkServerConf.getZkRetryBackoffStartMs(), bkServerConf.getZkRetryBackoffMaxMs(), Integer.MAX_VALUE); this.regExecutor = Executors.newSingleThreadScheduledExecutor( new ThreadFactoryBuilder().setNameFormat("registration-service-provider-scheduler").build()); }