当前位置: 首页>>代码示例>>Java>>正文


Java DeadlockDetectingListeningExecutorService类代码示例

本文整理汇总了Java中org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService的典型用法代码示例。如果您正苦于以下问题:Java DeadlockDetectingListeningExecutorService类的具体用法?Java DeadlockDetectingListeningExecutorService怎么用?Java DeadlockDetectingListeningExecutorService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DeadlockDetectingListeningExecutorService类属于org.opendaylight.yangtools.util.concurrent包,在下文中一共展示了DeadlockDetectingListeningExecutorService类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupStore

import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService; //导入依赖的package包/类
@Before
public void setupStore() {

    InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER",
            MoreExecutors.newDirectExecutorService());
    InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
            MoreExecutors.newDirectExecutorService());
    schemaContext = TestModel.createTestContext();

    operStore.onGlobalContextUpdated(schemaContext);
    configStore.onGlobalContextUpdated(schemaContext);

    ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore> builder() //
            .put(CONFIGURATION, configStore) //
            .put(OPERATIONAL, operStore) //
            .build();

    commitExecutor = new CommitExecutorService(Executors.newSingleThreadExecutor());
    futureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 5, "FCB");
    executor = new DeadlockDetectingListeningExecutorService(commitExecutor,
            TransactionCommitDeadlockException.DEADLOCK_EXCEPTION_SUPPLIER, futureExecutor);
    domBroker = new SerializedDOMDataBroker(stores, executor);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:DOMBrokerTest.java

示例2: setupStore

import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService; //导入依赖的package包/类
@Before
public void setupStore() {
    InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER",
            MoreExecutors.newDirectExecutorService());
    InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
            MoreExecutors.newDirectExecutorService());
    schemaContext = TestModel.createTestContext();

    operStore.onGlobalContextUpdated(schemaContext);
    configStore.onGlobalContextUpdated(schemaContext);

    ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder() //
            .put(CONFIGURATION, configStore) //
            .put(OPERATIONAL, operStore) //
            .build();

    commitExecutor = new CommitExecutorService(Executors.newSingleThreadExecutor());
    futureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 5, "FCB");
    executor = new DeadlockDetectingListeningExecutorService(commitExecutor,
            TransactionCommitDeadlockException.DEADLOCK_EXCEPTION_SUPPLIER, futureExecutor);
    domBroker = new SerializedDOMDataBroker(stores, executor);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:DOMDataTreeListenerTest.java

示例3: createInstance

import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService; //导入依赖的package包/类
@Override
public java.lang.AutoCloseable createInstance() {
    //Initializing Operational DOM DataStore defaulting to InMemoryDOMDataStore if one is not configured
    DOMStore operStore =  getOperationalDataStoreDependency();
    if(operStore == null){
       //we will default to InMemoryDOMDataStore creation
      operStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", getSchemaServiceDependency());
    }

    DOMStore configStore = getConfigDataStoreDependency();
    if(configStore == null){
       //we will default to InMemoryDOMDataStore creation
       configStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", getSchemaServiceDependency());
    }

    final Map<LogicalDatastoreType, DOMStore> datastores = new EnumMap<>(LogicalDatastoreType.class);
    datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
    datastores.put(LogicalDatastoreType.CONFIGURATION, configStore);

    /*
     * We use an executor for commit ListenableFuture callbacks that favors reusing available
     * threads over creating new threads at the expense of execution time. The assumption is
     * that most ListenableFuture callbacks won't execute a lot of business logic where we want
     * it to run quicker - many callbacks will likely just handle error conditions and do
     * nothing on success. The executor queue capacity is bounded and, if the capacity is
     * reached, subsequent submitted tasks will block the caller.
     */
    ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
            getMaxDataBrokerFutureCallbackPoolSize(), getMaxDataBrokerFutureCallbackQueueSize(),
            "CommitFutures");

    final List<AbstractMXBean> mBeans = Lists.newArrayList();
    final DurationStatisticsTracker commitStatsTracker;

    /*
     * We use a single-threaded executor for commits with a bounded queue capacity. If the
     * queue capacity is reached, subsequent commit tasks will be rejected and the commits will
     * fail. This is done to relieve back pressure. This should be an extreme scenario - either
     * there's deadlock(s) somewhere and the controller is unstable or some rogue component is
     * continuously hammering commits too fast or the controller is just over-capacity for the
     * system it's running on.
     */
    ExecutorService commitExecutor = SpecialExecutors.newBoundedSingleThreadExecutor(
        getMaxDataBrokerCommitQueueSize(), "WriteTxCommit");

    SerializedDOMDataBroker sdb = new SerializedDOMDataBroker(datastores,
        new DeadlockDetectingListeningExecutorService(commitExecutor,
            TransactionCommitDeadlockException.DEADLOCK_EXCEPTION_SUPPLIER,
            listenableFutureExecutor));
    commitStatsTracker = sdb.getCommitStatsTracker();

    final AbstractMXBean commitExecutorStatsMXBean =
            ThreadExecutorStatsMXBeanImpl.create(commitExecutor, "CommitExecutorStats",
                JMX_BEAN_TYPE, null);
    if(commitExecutorStatsMXBean != null) {
        mBeans.add(commitExecutorStatsMXBean);
    }

    if(commitStatsTracker != null) {
        final CommitStatsMXBeanImpl commitStatsMXBean = new CommitStatsMXBeanImpl(
                commitStatsTracker, JMX_BEAN_TYPE);
        commitStatsMXBean.registerMBean();
        mBeans.add(commitStatsMXBean);
    }

    final AbstractMXBean commitFutureStatsMXBean =
            ThreadExecutorStatsMXBeanImpl.create(listenableFutureExecutor,
                    "CommitFutureExecutorStats", JMX_BEAN_TYPE, null);
    if(commitFutureStatsMXBean != null) {
        mBeans.add(commitFutureStatsMXBean);
    }

    sdb.setCloseable(() -> mBeans.forEach(AbstractMXBean::unregisterMBean));

    return sdb;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:77,代码来源:DomInmemoryDataBrokerModule.java


注:本文中的org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。