当前位置: 首页>>代码示例>>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;未经允许,请勿转载。