Search in sources :

Example 1 with InMemoryDOMDataStore

use of org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore in project controller by opendaylight.

the class NormalizedNodeAggregatorTest method getRootNode.

public static NormalizedNode<?, ?> getRootNode(NormalizedNode<?, ?> moduleNode, SchemaContext schemaContext) throws ReadFailedException, ExecutionException, InterruptedException {
    try (InMemoryDOMDataStore store = new InMemoryDOMDataStore("test", Executors.newSingleThreadExecutor())) {
        store.onGlobalContextUpdated(schemaContext);
        DOMStoreWriteTransaction writeTransaction = store.newWriteOnlyTransaction();
        writeTransaction.merge(YangInstanceIdentifier.of(moduleNode.getNodeType()), moduleNode);
        DOMStoreThreePhaseCommitCohort ready = writeTransaction.ready();
        ready.canCommit().get();
        ready.preCommit().get();
        ready.commit().get();
        DOMStoreReadTransaction readTransaction = store.newReadOnlyTransaction();
        CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read = readTransaction.read(YangInstanceIdentifier.EMPTY);
        Optional<NormalizedNode<?, ?>> nodeOptional = read.checkedGet();
        return nodeOptional.get();
    }
}
Also used : ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) Optional(com.google.common.base.Optional) DOMStoreWriteTransaction(org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction) DOMStoreReadTransaction(org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction) InMemoryDOMDataStore(org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) DOMStoreThreePhaseCommitCohort(org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort)

Example 2 with InMemoryDOMDataStore

use of org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore in project controller by opendaylight.

the class ConcurrentDOMDataBrokerTest method setup.

@Before
public void setup() {
    doReturn("tx").when(transaction).getIdentifier();
    DOMStore store = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
    coordinator = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, store), futureExecutor);
}
Also used : DOMStore(org.opendaylight.mdsal.dom.spi.store.DOMStore) InMemoryDOMDataStore(org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore) Before(org.junit.Before)

Aggregations

InMemoryDOMDataStore (org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore)2 Optional (com.google.common.base.Optional)1 Before (org.junit.Before)1 ReadFailedException (org.opendaylight.mdsal.common.api.ReadFailedException)1 DOMStore (org.opendaylight.mdsal.dom.spi.store.DOMStore)1 DOMStoreReadTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction)1 DOMStoreThreePhaseCommitCohort (org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort)1 DOMStoreWriteTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction)1 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)1