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.apache.usergrid.persistence.graph.serialization.impl.shard.impl.AsyncTaskExecutorImpl.java

@Inject
public AsyncTaskExecutorImpl(final GraphFig graphFig) {
    this.taskExecutor = MoreExecutors.listeningDecorator(
            TaskExecutorFactory.createTaskExecutor("GraphTaskExecutor", graphFig.getShardAuditWorkerCount(),
                    graphFig.getShardAuditWorkerQueueSize(), TaskExecutorFactory.RejectionAction.ABORT));
}

From source file:org.apache.gobblin.util.executors.MDCPropagatingExecutorService.java

public MDCPropagatingExecutorService(ExecutorService executorService) {
    if (executorService instanceof ListeningExecutorService) {
        this.executorService = (ListeningExecutorService) executorService;
    } else {/*w  w  w  .  ja  va  2s. c  o  m*/
        this.executorService = MoreExecutors.listeningDecorator(executorService);
    }
}

From source file:com.stegosaurus.concurrent.ListeningExecutorServiceProvider.java

/**
 * Get an executor service for this application.
 * @return the executor service./*from w ww .  j  a va 2 s.  co  m*/
 */
public ListeningExecutorService get() {
    if (service == null) {
        service = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
    }
    return service;
}

From source file:com.spectralogic.ds3client.helpers.strategy.transferstrategy.SingleThreadedTransferStrategy.java

public SingleThreadedTransferStrategy(final BlobStrategy blobStrategy, final JobState jobState,
        final EventDispatcher eventDispatcher, final MasterObjectList masterObjectList,
        final FailureEvent.FailureActivity failureActivity) {
    super(blobStrategy, jobState, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()),
            eventDispatcher, masterObjectList, failureActivity);
}

From source file:com.google.cloud.tools.managedcloudsdk.command.AsyncByteConsumer.java

/** Create a new instance. */
AsyncByteConsumer(ByteHandler byteHandler) {
    this(Preconditions.checkNotNull(byteHandler),
            MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()),
            SettableFuture.<String>create());
}

From source file:org.pentaho.reporting.platform.plugin.async.DelegatedListenableExecutor.java

public DelegatedListenableExecutor(final ExecutorService delegateExecutor) {
    ArgumentNullException.validate("delegateExecutor", delegateExecutor);
    this.delegateExecutor = MoreExecutors.listeningDecorator(delegateExecutor);
}

From source file:org.eclipse.scada.protocol.iec60870.server.data.AbstractBaseDataModel.java

public AbstractBaseDataModel(final String threadName) {
    this.executor = MoreExecutors.listeningDecorator(
            Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory(threadName, false, true)));
}

From source file:com.spectralogic.ds3client.helpers.strategy.transferstrategy.MultiThreadedTransferStrategy.java

public MultiThreadedTransferStrategy(final BlobStrategy blobStrategy, final JobState jobState,
        final int numConcurrentTransferThreads, final EventDispatcher eventDispatcher,
        final MasterObjectList masterObjectList, final FailureEvent.FailureActivity failureActivity) {
    super(blobStrategy, jobState,
            MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(numConcurrentTransferThreads)),
            eventDispatcher, masterObjectList, failureActivity);
}

From source file:org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory.java

/**
 * Creates an InMemoryDOMDataStore instance.
 *
 * @param name the name of the data store
 * @param schemaService the SchemaService to which to register the data store.
 * @param properties configuration properties for the InMemoryDOMDataStore instance. If null,
 *                   default property values are used.
 * @return an InMemoryDOMDataStore instance
 *///www .j a v  a2s.  c  o  m
public static InMemoryDOMDataStore create(final String name, @Nullable final SchemaService schemaService,
        @Nullable final InMemoryDOMDataStoreConfigProperties properties) {

    InMemoryDOMDataStoreConfigProperties actualProperties = properties;
    if (actualProperties == null) {
        actualProperties = InMemoryDOMDataStoreConfigProperties.getDefault();
    }

    // For DataChangeListener notifications we use an executor that provides the fastest
    // task execution time to get higher throughput as DataChangeListeners typically provide
    // much of the business logic for a data model. If the executor queue size limit is reached,
    // subsequent submitted notifications will block the calling thread.

    int dclExecutorMaxQueueSize = actualProperties.getMaxDataChangeExecutorQueueSize();
    int dclExecutorMaxPoolSize = actualProperties.getMaxDataChangeExecutorPoolSize();

    ExecutorService dataChangeListenerExecutor = SpecialExecutors
            .newBlockingBoundedFastThreadPool(dclExecutorMaxPoolSize, dclExecutorMaxQueueSize, name + "-DCL");

    InMemoryDOMDataStore dataStore = new InMemoryDOMDataStore(name,
            MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()), dataChangeListenerExecutor,
            actualProperties.getMaxDataChangeListenerQueueSize());

    if (schemaService != null) {
        schemaService.registerSchemaContextListener(dataStore);
    }

    return dataStore;
}

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

/**
 * Starts the manager.//from  w w w .  j a va2  s  .  co m
 */
@PostConstruct
public void start() {
    final ExecutorService executorService = newFixedThreadPool(config.getServiceMaxNumberOfThreads(),
            "metacat-service-pool-%d", 1000);
    executor = MoreExecutors.listeningDecorator(executorService);
}