Search in sources :

Example 1 with DOMStore

use of org.opendaylight.controller.sal.core.spi.data.DOMStore in project controller by opendaylight.

the class DOMBrokerTest method setupStore.

@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);
    final 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", DOMBrokerTest.class);
    executor = new DeadlockDetectingListeningExecutorService(commitExecutor, TransactionCommitDeadlockException.DEADLOCK_EXCEPTION_SUPPLIER, futureExecutor);
    domBroker = new SerializedDOMDataBroker(stores, executor);
}
Also used : DOMStore(org.opendaylight.controller.sal.core.spi.data.DOMStore) InMemoryDOMDataStore(org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) DeadlockDetectingListeningExecutorService(org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService) Before(org.junit.Before)

Example 2 with DOMStore

use of org.opendaylight.controller.sal.core.spi.data.DOMStore in project controller by opendaylight.

the class AbstractDOMDataBroker method registerDataChangeListener.

@Override
public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store, final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) {
    DOMStore potentialStore = getTxFactories().get(store);
    checkState(potentialStore != null, "Requested logical data store is not available.");
    return potentialStore.registerChangeListener(path, listener, triggeringScope);
}
Also used : DOMStore(org.opendaylight.controller.sal.core.spi.data.DOMStore)

Example 3 with DOMStore

use of org.opendaylight.controller.sal.core.spi.data.DOMStore in project controller by opendaylight.

the class DomInmemoryDataBrokerModule method createInstance.

@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", SerializedDOMDataBroker.class);
    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.class);
    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;
}
Also used : AbstractMXBean(org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean) DOMStore(org.opendaylight.controller.sal.core.spi.data.DOMStore) DeadlockDetectingListeningExecutorService(org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService) ExecutorService(java.util.concurrent.ExecutorService) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) DurationStatisticsTracker(org.opendaylight.yangtools.util.DurationStatisticsTracker) EnumMap(java.util.EnumMap) SerializedDOMDataBroker(org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker) DeadlockDetectingListeningExecutorService(org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService) CommitStatsMXBeanImpl(org.opendaylight.controller.md.sal.dom.broker.impl.jmx.CommitStatsMXBeanImpl)

Example 4 with DOMStore

use of org.opendaylight.controller.sal.core.spi.data.DOMStore in project controller by opendaylight.

the class BindingTestContext method startNewDomDataBroker.

public void startNewDomDataBroker() {
    checkState(this.executor != null, "Executor needs to be set");
    final InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
    final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService());
    this.newDatastores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder().put(LogicalDatastoreType.OPERATIONAL, operStore).put(LogicalDatastoreType.CONFIGURATION, configStore).build();
    this.newDOMDataBroker = new SerializedDOMDataBroker(this.newDatastores, this.executor);
    this.mockSchemaService.registerSchemaContextListener(configStore);
    this.mockSchemaService.registerSchemaContextListener(operStore);
}
Also used : DOMStore(org.opendaylight.controller.sal.core.spi.data.DOMStore) InMemoryDOMDataStore(org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) SerializedDOMDataBroker(org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker)

Example 5 with DOMStore

use of org.opendaylight.controller.sal.core.spi.data.DOMStore in project controller by opendaylight.

the class InMemoryBrokerWriteTransactionBenchmark method setUp.

@Setup(Level.Trial)
@Override
public void setUp() throws Exception {
    ListeningExecutorService dsExec = MoreExecutors.newDirectExecutorService();
    executor = MoreExecutors.listeningDecorator(MoreExecutors.getExitingExecutorService((ThreadPoolExecutor) Executors.newFixedThreadPool(1), 1L, TimeUnit.SECONDS));
    InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", dsExec);
    InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", dsExec);
    Map<LogicalDatastoreType, DOMStore> datastores = ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, (DOMStore) operStore, LogicalDatastoreType.CONFIGURATION, configStore);
    domBroker = new SerializedDOMDataBroker(datastores, executor);
    schemaContext = BenchmarkModel.createTestContext();
    configStore.onGlobalContextUpdated(schemaContext);
    operStore.onGlobalContextUpdated(schemaContext);
    initTestNode();
}
Also used : DOMStore(org.opendaylight.controller.sal.core.spi.data.DOMStore) InMemoryDOMDataStore(org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) SerializedDOMDataBroker(org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

DOMStore (org.opendaylight.controller.sal.core.spi.data.DOMStore)8 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)7 InMemoryDOMDataStore (org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore)6 Before (org.junit.Before)4 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)3 SerializedDOMDataBroker (org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker)3 DeadlockDetectingListeningExecutorService (org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService)3 EnumMap (java.util.EnumMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 AbstractMXBean (org.opendaylight.controller.md.sal.common.util.jmx.AbstractMXBean)1 CommitStatsMXBeanImpl (org.opendaylight.controller.md.sal.dom.broker.impl.jmx.CommitStatsMXBeanImpl)1 DurationStatisticsTracker (org.opendaylight.yangtools.util.DurationStatisticsTracker)1 Setup (org.openjdk.jmh.annotations.Setup)1