當前位置: 首頁>>代碼示例>>Java>>正文


Java MoreExecutors.directExecutor方法代碼示例

本文整理匯總了Java中com.google.common.util.concurrent.MoreExecutors.directExecutor方法的典型用法代碼示例。如果您正苦於以下問題:Java MoreExecutors.directExecutor方法的具體用法?Java MoreExecutors.directExecutor怎麽用?Java MoreExecutors.directExecutor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.util.concurrent.MoreExecutors的用法示例。


在下文中一共展示了MoreExecutors.directExecutor方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: activate

import com.google.common.util.concurrent.MoreExecutors; //導入方法依賴的package包/類
@Activate
public void activate(ComponentContext context) {
    configService.registerProperties(getClass());
    setupCodecs();
    messageReceivingExecutor = receiveOnIOLoopThread
            ? MoreExecutors.directExecutor()
            : Executors.newFixedThreadPool(
                    totalReceiverThreads,
                    groupedThreads("onos/net-perf-test", "receiver-%d"));
    registerMessageHandlers();
    startTest();
    reporter.scheduleWithFixedDelay(this::reportPerformance,
            reportIntervalSeconds,
            reportIntervalSeconds,
            TimeUnit.SECONDS);
    logConfig("Started");
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:18,代碼來源:MessagingPerfApp.java

示例2: from

import com.google.common.util.concurrent.MoreExecutors; //導入方法依賴的package包/類
/**
 * Wraps listenable future with a fluent future.
 * @param <V> value type
 * @param future future
 * @return fluent instance
 */
public static <V> FluentFuture<V> from(ListenableFuture<V> future) {
  if (future instanceof FluentFuture<?>) {
    return (FluentFuture<V>) future;
  }
  return new WrapingFluentFuture<>(future, MoreExecutors.directExecutor());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:FluentFutures.java

示例3: EventBus

import com.google.common.util.concurrent.MoreExecutors; //導入方法依賴的package包/類
/**
 * Creates a new EventBus with the given {@code identifier}.
 *
 * @param identifier a brief name for this bus, for logging purposes. Should be a valid Java
 *     identifier.
 */
public EventBus(String identifier) {
  this(
      identifier,
      MoreExecutors.directExecutor(),
      Dispatcher.perThreadDispatchQueue(),
      LoggingHandler.INSTANCE);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:14,代碼來源:EventBus.java

示例4: wrapExecutor

import com.google.common.util.concurrent.MoreExecutors; //導入方法依賴的package包/類
/**
 * returns an Executor that will either execute the command given the Executor delegate or
 * call the callback.onFailure if it receives a (Es)RejectedExecutionException
 */
public static Executor wrapExecutor(Executor delegate, FutureCallback<?> callback) {
    if (delegate == MoreExecutors.directExecutor()) {
        // directExecutor won't reject anything...
        return delegate;
    }

    return new RejectionAwareExecutor(delegate, callback);
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:13,代碼來源:RejectionAwareExecutor.java

示例5: testChainedTransactionFailureWithSingleShard

import com.google.common.util.concurrent.MoreExecutors; //導入方法依賴的package包/類
@Test
public void testChainedTransactionFailureWithSingleShard() throws Exception {
    initDatastoresWithCars("testChainedTransactionFailureWithSingleShard");

    final ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
            ImmutableMap.<LogicalDatastoreType, DOMStore>builder().put(
                    LogicalDatastoreType.CONFIGURATION, followerDistributedDataStore).build(),
                    MoreExecutors.directExecutor());

    final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
    final DOMTransactionChain txChain = broker.createTransactionChain(listener);

    final DOMDataWriteTransaction writeTx = txChain.newWriteOnlyTransaction();

    final ContainerNode invalidData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
            new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME))
                .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build();

    writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData);

    try {
        writeTx.submit().checkedGet(5, TimeUnit.SECONDS);
        fail("Expected TransactionCommitFailedException");
    } catch (final TransactionCommitFailedException e) {
        // Expected
    }

    verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx), any(Throwable.class));

    txChain.close();
    broker.close();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:33,代碼來源:DistributedDataStoreRemotingIntegrationTest.java

示例6: testChainedTransactionFailureWithMultipleShards

import com.google.common.util.concurrent.MoreExecutors; //導入方法依賴的package包/類
@Test
public void testChainedTransactionFailureWithMultipleShards() throws Exception {
    initDatastoresWithCarsAndPeople("testChainedTransactionFailureWithMultipleShards");

    final ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
            ImmutableMap.<LogicalDatastoreType, DOMStore>builder().put(
                    LogicalDatastoreType.CONFIGURATION, followerDistributedDataStore).build(),
                    MoreExecutors.directExecutor());

    final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
    final DOMTransactionChain txChain = broker.createTransactionChain(listener);

    final DOMDataWriteTransaction writeTx = txChain.newWriteOnlyTransaction();

    writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH, PeopleModel.emptyContainer());

    final ContainerNode invalidData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(
            new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME))
                .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build();

    // Note that merge will validate the data and fail but put succeeds b/c deep validation is not
    // done for put for performance reasons.
    writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData);

    try {
        writeTx.submit().checkedGet(5, TimeUnit.SECONDS);
        fail("Expected TransactionCommitFailedException");
    } catch (final TransactionCommitFailedException e) {
        // Expected
    }

    verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx), any(Throwable.class));

    txChain.close();
    broker.close();
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:37,代碼來源:DistributedDataStoreRemotingIntegrationTest.java

示例7: executor

import com.google.common.util.concurrent.MoreExecutors; //導入方法依賴的package包/類
@Provides
@Production
static Executor executor() {
  return MoreExecutors.directExecutor();
}
 
開發者ID:curioswitch,項目名稱:curiostack,代碼行數:6,代碼來源:DatabaseTestingModule.java

示例8: testCreateChainedTransactionsInQuickSuccession

import com.google.common.util.concurrent.MoreExecutors; //導入方法依賴的package包/類
@Test
public void testCreateChainedTransactionsInQuickSuccession() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "testCreateChainedTransactionsInQuickSuccession", "cars-1")) {

                final ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
                        ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
                                .put(LogicalDatastoreType.CONFIGURATION, dataStore).build(),
                        MoreExecutors.directExecutor());

                final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
                DOMTransactionChain txChain = broker.createTransactionChain(listener);

                final List<CheckedFuture<Void, TransactionCommitFailedException>> futures = new ArrayList<>();

                final DOMDataWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
                writeTx.put(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, CarsModel.emptyContainer());
                writeTx.put(LogicalDatastoreType.CONFIGURATION, CarsModel.CAR_LIST_PATH, CarsModel.newCarMapNode());
                futures.add(writeTx.submit());

                int numCars = 100;
                for (int i = 0; i < numCars; i++) {
                    final DOMDataReadWriteTransaction rwTx = txChain.newReadWriteTransaction();

                    rwTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.newCarPath("car" + i),
                            CarsModel.newCarEntry("car" + i, BigInteger.valueOf(20000)));

                    futures.add(rwTx.submit());
                }

                for (final CheckedFuture<Void, TransactionCommitFailedException> f : futures) {
                    f.checkedGet();
                }

                final Optional<NormalizedNode<?, ?>> optional = txChain.newReadOnlyTransaction()
                        .read(LogicalDatastoreType.CONFIGURATION, CarsModel.CAR_LIST_PATH).get(5, TimeUnit.SECONDS);
                assertEquals("isPresent", true, optional.isPresent());
                assertEquals("# cars", numCars, ((Collection<?>) optional.get().getValue()).size());

                txChain.close();

                broker.close();
            }
        }
    };
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:49,代碼來源:DistributedDataStoreIntegrationTest.java

示例9: testChainedTransactionFailureWithSingleShard

import com.google.common.util.concurrent.MoreExecutors; //導入方法依賴的package包/類
@Test
public void testChainedTransactionFailureWithSingleShard() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "testChainedTransactionFailureWithSingleShard", "cars-1")) {

                final ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
                        ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
                                .put(LogicalDatastoreType.CONFIGURATION, dataStore).build(),
                        MoreExecutors.directExecutor());

                final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
                final DOMTransactionChain txChain = broker.createTransactionChain(listener);

                final DOMDataReadWriteTransaction writeTx = txChain.newReadWriteTransaction();

                writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH,
                        PeopleModel.emptyContainer());

                final ContainerNode invalidData = ImmutableContainerNodeBuilder.create()
                        .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME))
                        .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build();

                writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData);

                try {
                    writeTx.submit().checkedGet(5, TimeUnit.SECONDS);
                    fail("Expected TransactionCommitFailedException");
                } catch (final TransactionCommitFailedException e) {
                    // Expected
                }

                verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx),
                        any(Throwable.class));

                txChain.close();
                broker.close();
            }
        }
    };
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:43,代碼來源:DistributedDataStoreIntegrationTest.java

示例10: testChainedTransactionFailureWithMultipleShards

import com.google.common.util.concurrent.MoreExecutors; //導入方法依賴的package包/類
@Test
public void testChainedTransactionFailureWithMultipleShards() throws Exception {
    new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
        {
            try (AbstractDataStore dataStore = setupAbstractDataStore(
                    testParameter, "testChainedTransactionFailureWithMultipleShards", "cars-1", "people-1")) {

                final ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(
                        ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
                                .put(LogicalDatastoreType.CONFIGURATION, dataStore).build(),
                        MoreExecutors.directExecutor());

                final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
                final DOMTransactionChain txChain = broker.createTransactionChain(listener);

                final DOMDataReadWriteTransaction writeTx = txChain.newReadWriteTransaction();

                writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH,
                        PeopleModel.emptyContainer());

                final ContainerNode invalidData = ImmutableContainerNodeBuilder.create()
                        .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME))
                        .withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build();

                writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData);

                // Note that merge will validate the data and fail but put
                // succeeds b/c deep validation is not
                // done for put for performance reasons.
                try {
                    writeTx.submit().checkedGet(5, TimeUnit.SECONDS);
                    fail("Expected TransactionCommitFailedException");
                } catch (final TransactionCommitFailedException e) {
                    // Expected
                }

                verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx),
                        any(Throwable.class));

                txChain.close();
                broker.close();
            }
        }
    };
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:46,代碼來源:DistributedDataStoreIntegrationTest.java


注:本文中的com.google.common.util.concurrent.MoreExecutors.directExecutor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。