List of usage examples for com.google.common.util.concurrent MoreExecutors listeningDecorator
@GwtIncompatible("TODO") public static ListeningScheduledExecutorService listeningDecorator(ScheduledExecutorService delegate)
From source file:org.apache.fluo.core.async.AsyncConditionalWriter.java
public AsyncConditionalWriter(Environment env, ConditionalWriter cw) { this.cw = cw; int numThreads = env.getConfiguration().getInt(FluoConfigurationImpl.ASYNC_CW_THREADS, FluoConfigurationImpl.ASYNC_CW_THREADS_DEFAULT); int permits = env.getConfiguration().getInt(FluoConfigurationImpl.ASYNC_CW_LIMIT, FluoConfigurationImpl.ASYNC_CW_LIMIT_DEFAULT); this.les = MoreExecutors.listeningDecorator(FluoExecutors.newFixedThreadPool(numThreads, "asyncCW")); // the conditional writer currently has not memory limits... give it too much and it blows out // memory.. need to fix this in conditional writer // for now this needs to be memory based this.semaphore = new Limit(permits); }
From source file:com.google.javascript.jscomp.PrebuildAst.java
void prebuild(Iterable<CompilerInput> allInputs) { ThreadFactory threadFactory = new ThreadFactory() { @Override//from w w w.ja v a 2s.c om public Thread newThread(Runnable r) { Thread t = new Thread(null, r, "jscompiler-PrebuildAst", CompilerExecutor.COMPILER_STACK_SIZE); t.setDaemon(true); // Do not prevent the JVM from exiting. return t; } }; ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(numParallelThreads, numParallelThreads, Integer.MAX_VALUE, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory); ListeningExecutorService executorService = MoreExecutors.listeningDecorator(poolExecutor); List<ListenableFuture<?>> futureList = new ArrayList<>(Iterables.size(allInputs)); // TODO(moz): Support canceling all parsing on the first halting error for (final CompilerInput input : allInputs) { futureList.add(executorService.submit(new Runnable() { @Override public void run() { input.getAstRoot(compiler); } })); } poolExecutor.shutdown(); try { Futures.allAsList(futureList).get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } }
From source file:com.netflix.astyanax.util.WriteAheadMutationBatchExecutor.java
public WriteAheadMutationBatchExecutor(Keyspace keyspace, ExecutorService executor) { this.executor = MoreExecutors.listeningDecorator(executor); this.keyspace = keyspace; }
From source file:org.opendaylight.infrautils.utils.concurrent.Executors.java
public static ListeningScheduledExecutorService newListeningSingleThreadScheduledExecutor(String namePrefix, Logger logger) {//from w w w .ja va 2 s . com return MoreExecutors.listeningDecorator(newSingleThreadScheduledExecutor(namePrefix, logger)); }
From source file:org.apache.tez.dag.app.TezTestServiceCommunicator.java
public TezTestServiceCommunicator(int numThreads) { super(TezTestServiceCommunicator.class.getSimpleName()); ExecutorService localExecutor = Executors.newFixedThreadPool(numThreads, new ThreadFactoryBuilder().setNameFormat("TezTestServiceCommunicator #%2d").build()); this.hostProxies = new ConcurrentHashMap<String, TezTestServiceProtocolBlockingPB>(); executor = MoreExecutors.listeningDecorator(localExecutor); }
From source file:org.apache.druid.query.groupby.GroupByQueryRunnerFactory.java
@Override public QueryRunner<Row> mergeRunners(final ExecutorService exec, final Iterable<QueryRunner<Row>> queryRunners) { // mergeRunners should take ListeningExecutorService at some point final ListeningExecutorService queryExecutor = MoreExecutors.listeningDecorator(exec); return new QueryRunner<Row>() { @Override/*from w ww .ja v a 2s. co m*/ public Sequence<Row> run(QueryPlus<Row> queryPlus, Map<String, Object> responseContext) { QueryRunner<Row> rowQueryRunner = strategySelector.strategize((GroupByQuery) queryPlus.getQuery()) .mergeRunners(queryExecutor, queryRunners); return rowQueryRunner.run(queryPlus, responseContext); } }; }
From source file:com.vmware.photon.controller.dhcpagent.DHCPAgentModule.java
@Override protected void configure() { bind(BuildInfo.class).toInstance(BuildInfo.get(this.getClass())); bind(DHCPAgentConfig.class).toInstance(dhcpAgentConfig); bind(XenonConfig.class).toInstance(dhcpAgentConfig.getXenonConfig()); bind(DHCPDriver.class).toInstance(dhcpDriver); bind(ListeningExecutorService.class).toInstance(MoreExecutors.listeningDecorator( new ThreadPoolExecutor(DHCPAgentDefaults.CORE_POOL_SIZE, DHCPAgentDefaults.MAXIMUM_POOL_SIZE, DHCPAgentDefaults.KEEP_ALIVE_TIME, TimeUnit.SECONDS, blockingQueue))); }
From source file:org.restcomm.media.bootstrap.ioc.provider.ListeningScheduledExecutorServiceProvider.java
@Override public ListeningScheduledExecutorService get() { ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("mgcp-%d").build(); // TODO set uncaught exception handler // ThreadPoolExecutor executor = new ThreadPoolExecutor(POOL_SIZE, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new // SynchronousQueue<Runnable>(), threadFactory); // executor.allowCoreThreadTimeOut(false); // Executors.newScheduledThreadPool(POOL_SIZE, threadFactory); // return MoreExecutors.listeningDecorator(executor); ScheduledThreadPoolExecutor executor = (ScheduledThreadPoolExecutor) Executors .newScheduledThreadPool(POOL_SIZE, threadFactory); executor.prestartAllCoreThreads();// w w w. j a v a2 s . co m executor.setRemoveOnCancelPolicy(true); return MoreExecutors.listeningDecorator(executor); }
From source file:com.google.caliper.runner.CaliperRunnerModule.java
@Provides @Singleton/*from ww w .j a v a 2 s . c o m*/ @TrialExecutor static ListeningExecutorService provideTrialExecutorService(CaliperConfig config) { int poolSize = Integer.parseInt(config.properties().get(RUNNER_MAX_PARALLELISM_OPTION)); return MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(poolSize)); }
From source file:org.pentaho.di.trans.dataservice.optimization.cache.ServiceCacheFactory.java
public ServiceCacheFactory(PentahoCacheManager cacheManager, ExecutorService executorService) { this.cacheManager = cacheManager; this.executorService = MoreExecutors.listeningDecorator(executorService); }