Example usage for com.google.common.util.concurrent MoreExecutors listeningDecorator

List of usage examples for com.google.common.util.concurrent MoreExecutors listeningDecorator

Introduction

In this page you can find the example usage for com.google.common.util.concurrent MoreExecutors listeningDecorator.

Prototype

@GwtIncompatible("TODO")
public static ListeningScheduledExecutorService listeningDecorator(ScheduledExecutorService delegate) 

Source Link

Document

Creates a ScheduledExecutorService whose submit and invokeAll methods submit ListenableFutureTask instances to the given delegate executor.

Usage

From source file:org.jclouds.chef.strategy.internal.ListNodesInEnvironmentImpl.java

@Override
public Iterable<? extends Node> execute(ExecutorService executor, String environmentName) {
    return this.executeConcurrently(MoreExecutors.listeningDecorator(executor), environmentName);
}

From source file:org.apache.hadoop.hdfs.storageservice.server.RequestCallableExecutor.java

public RequestCallableExecutor(Configuration con) {
    requestsQueue = new SynchronousQueue<Runnable>();
    // TODO: this needs to be scalable and externally configurable
    underlyingExecutor = new ThreadPoolExecutor(1, 1, 1L, TimeUnit.SECONDS, requestsQueue);
    callExecutor = MoreExecutors.listeningDecorator(underlyingExecutor);
}

From source file:com.turn.sorcerer.executor.TaskScheduler.java

public TaskScheduler(ExecutablePipeline pipeline, int jobId, int numOfThreads,
        Map<TaskType, Map<String, String>> taskArgMap, boolean adhoc, boolean overwriteTasks) {
    this.pipeline = pipeline;
    this.taskArgMap = taskArgMap;
    this.adhoc = adhoc;
    this.jobId = jobId;
    this.ignoreTaskComplete = overwriteTasks;

    if (numOfThreads > 0) {
        executionPool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(numOfThreads));
    } else {//from ww w  .  j a v a  2 s .  c om
        executionPool = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
    }
    runningTasks = Maps.newConcurrentMap();

}

From source file:co.cask.cdap.client.rest.RestStreamWriter.java

public RestStreamWriter(RestClient restClient, int writerPoolSize, String streamName) {
    this.restClient = restClient;
    this.streamName = streamName;
    this.pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(writerPoolSize));
}

From source file:com.flipkart.hydra.task.entities.WrapperCallable.java

public WrapperCallable(ExecutorService executor, Class<? extends Callable> callableClass, Composer loopComposer,
        Composer composer, Map<String, Object> values)
        throws NoSuchMethodException, ComposerEvaluationException {
    this(MoreExecutors.listeningDecorator(executor),
            ReflectionHelper.getFirstSingleArgConstructor(callableClass), loopComposer.compose(values),
            composer, values);//from  www . j  av a 2  s.co  m
}

From source file:com.netflix.metacat.common.server.util.ThreadServiceManager.java

/**
 * Constructor.//from  www  .j  a v a2  s.  c  o m
 *
 * @param registry registry for spectator
 * @param config Program configuration
 */
@Autowired
public ThreadServiceManager(final Registry registry, final Config config) {
    final ExecutorService executorService = newFixedThreadPool(config.getServiceMaxNumberOfThreads(),
            "metacat-service-pool-%d", 1000);
    this.executor = MoreExecutors.listeningDecorator(executorService);
    RegistryUtil.registerThreadPool(registry, "metacat-service-pool", (ThreadPoolExecutor) executorService);
}

From source file:com.google.jimfs.JimfsAsynchronousFileChannel.java

public JimfsAsynchronousFileChannel(JimfsFileChannel channel, ExecutorService executor) {
    this.channel = checkNotNull(channel);
    this.executor = MoreExecutors.listeningDecorator(executor);
}

From source file:com.hortonworks.registries.cache.view.io.loader.CacheLoaderAsync.java

public CacheLoaderAsync(Cache<K, V> cache, DataStoreReader<K, V> dataStoreReader,
        ExecutorService executorService) {
    super(cache, dataStoreReader);
    this.executorService = MoreExecutors.listeningDecorator(executorService);
}

From source file:com.google.gerrit.server.git.ReceiveCommitsExecutorModule.java

@Provides
@Singleton/* ww w.j av a 2 s.co  m*/
@ChangeUpdateExecutor
public ListeningExecutorService createChangeUpdateExecutor(@GerritServerConfig Config config) {
    int poolSize = config.getInt("receive", null, "changeUpdateThreads", 1);
    if (poolSize <= 1) {
        return MoreExecutors.sameThreadExecutor();
    }
    return MoreExecutors.listeningDecorator(MoreExecutors.getExitingExecutorService(new ThreadPoolExecutor(1,
            poolSize, 10, TimeUnit.MINUTES, new ArrayBlockingQueue<Runnable>(poolSize),
            new ThreadFactoryBuilder().setNameFormat("ChangeUpdate-%d").setDaemon(true).build(),
            new ThreadPoolExecutor.CallerRunsPolicy())));
}

From source file:qa.qcri.nadeef.core.pipeline.ViolationDetector.java

/**
 * Violation detector constructor./*from w w  w  .ja  v a 2  s  .c o  m*/
 */
public ViolationDetector(ExecutionContext context) {
    super(context);
    resultCollection = Lists.newArrayList();
    ThreadFactory factory = new ThreadFactoryBuilder().setNameFormat("detect-pool-%d").build();
    service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(MAX_THREAD_NUM, factory));
}