X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FInMemoryDOMDataStore.java;h=3582ff6ef1061749f1649cc58aed21def801d002;hp=a85d8ac3fb645ecc5a5815df3aeaf46bb8fc4187;hb=7292faba613ab556babd7bbcdd78984f5668bf9b;hpb=a54ec60368110d22794602343c934902f6833c65 diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java index a85d8ac3fb..3582ff6ef1 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java @@ -7,13 +7,14 @@ */ package org.opendaylight.controller.md.sal.dom.store.impl; -import com.google.common.base.Optional; import com.google.common.base.Preconditions; +import java.util.Optional; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree; import org.opendaylight.controller.sal.core.spi.data.DOMStore; @@ -36,6 +37,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; @@ -58,18 +60,14 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class); private static final Invoker, DOMImmutableDataChangeEvent> DCL_NOTIFICATION_MGR_INVOKER = - new Invoker, DOMImmutableDataChangeEvent>() { - @Override - public void invokeListener(final DataChangeListenerRegistration listener, - final DOMImmutableDataChangeEvent notification ) { - final AsyncDataChangeListener> inst = listener.getInstance(); - if (inst != null) { - inst.onDataChanged(notification); - } + (listener, notification) -> { + final AsyncDataChangeListener> inst = listener.getInstance(); + if (inst != null) { + inst.onDataChanged(notification); } }; - private final DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(); + private final DataTree dataTree; private final ListenerTree listenerTree = ListenerTree.create(); private final AtomicLong txCounter = new AtomicLong(0); @@ -82,10 +80,12 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl private volatile AutoCloseable closeable; public InMemoryDOMDataStore(final String name, final ExecutorService dataChangeListenerExecutor) { - this(name, dataChangeListenerExecutor, InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE, false); + this(name, LogicalDatastoreType.OPERATIONAL, dataChangeListenerExecutor, + InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE, false); } - public InMemoryDOMDataStore(final String name, final ExecutorService dataChangeListenerExecutor, + public InMemoryDOMDataStore(final String name, final LogicalDatastoreType type, + final ExecutorService dataChangeListenerExecutor, final int maxDataChangeListenerQueueSize, final boolean debugTransactions) { this.name = Preconditions.checkNotNull(name); this.dataChangeListenerExecutor = Preconditions.checkNotNull(dataChangeListenerExecutor); @@ -96,6 +96,17 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl DCL_NOTIFICATION_MGR_INVOKER, maxDataChangeListenerQueueSize, "DataChangeListenerQueueMgr"); changePublisher = new InMemoryDOMStoreTreeChangePublisher(this.dataChangeListenerExecutor, maxDataChangeListenerQueueSize); + + switch (type) { + case CONFIGURATION: + dataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION); + break; + case OPERATIONAL: + dataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL); + break; + default: + throw new IllegalArgumentException("Data store " + type + " not supported"); + } } public void setCloseable(final AutoCloseable closeable) { @@ -212,9 +223,11 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl } @Override - protected DOMStoreThreePhaseCommitCohort transactionReady(final SnapshotBackedWriteTransaction tx, final DataTreeModification modification) { + protected DOMStoreThreePhaseCommitCohort transactionReady(final SnapshotBackedWriteTransaction tx, + final DataTreeModification modification, + final Exception readyError) { LOG.debug("Tx: {} is submitted. Modifications: {}", tx.getIdentifier(), modification); - return new InMemoryDOMStoreThreePhaseCommitCohort(this, tx, modification); + return new InMemoryDOMStoreThreePhaseCommitCohort(this, tx, modification, readyError); } String nextIdentifier() {