Search in sources :

Example 11 with DOMStore

use of org.opendaylight.mdsal.dom.spi.store.DOMStore 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)

Example 12 with DOMStore

use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.

the class ConcurrentDOMDataBrokerTest method testLazySubTransactionCreationForReadWriteTransactions.

@Test
public void testLazySubTransactionCreationForReadWriteTransactions() {
    DOMStore configDomStore = mock(DOMStore.class);
    DOMStore operationalDomStore = mock(DOMStore.class);
    DOMStoreReadWriteTransaction storeTxn = mock(DOMStoreReadWriteTransaction.class);
    doReturn(storeTxn).when(operationalDomStore).newReadWriteTransaction();
    doReturn(storeTxn).when(configDomStore).newReadWriteTransaction();
    try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, operationalDomStore, LogicalDatastoreType.CONFIGURATION, configDomStore), futureExecutor)) {
        DOMDataTreeReadWriteTransaction dataTxn = dataBroker.newReadWriteTransaction();
        dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
        dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
        dataTxn.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
        verify(configDomStore, never()).newReadWriteTransaction();
        verify(operationalDomStore, times(1)).newReadWriteTransaction();
        dataTxn.put(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
        verify(configDomStore, times(1)).newReadWriteTransaction();
        verify(operationalDomStore, times(1)).newReadWriteTransaction();
    }
}
Also used : DOMDataTreeReadWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction) DOMStore(org.opendaylight.mdsal.dom.spi.store.DOMStore) DOMStoreReadWriteTransaction(org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Example 13 with DOMStore

use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.

the class ConcurrentDOMDataBrokerTest method testCreateTransactionChain.

@Test
public void testCreateTransactionChain() {
    DOMStore domStore = mock(DOMStore.class);
    try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor)) {
        dataBroker.createTransactionChain(mock(TransactionChainListener.class));
        verify(domStore, times(2)).createTransactionChain();
    }
}
Also used : TransactionChainListener(org.opendaylight.mdsal.common.api.TransactionChainListener) DOMStore(org.opendaylight.mdsal.dom.spi.store.DOMStore) Test(org.junit.Test)

Aggregations

DOMStore (org.opendaylight.mdsal.dom.spi.store.DOMStore)13 Test (org.junit.Test)11 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)4 DOMStoreReadWriteTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction)4 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)4 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)3 DOMDataTreeReadWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 TransactionChainListener (org.opendaylight.mdsal.common.api.TransactionChainListener)2 DOMStoreThreePhaseCommitCohort (org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort)2 Before (org.junit.Before)1 DOMDataTreeReadTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction)1 DOMTransactionChain (org.opendaylight.mdsal.dom.api.DOMTransactionChain)1 DOMStoreReadTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction)1 DOMStoreTransactionChain (org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain)1 DOMStoreWriteTransaction (org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction)1 InMemoryDOMDataStore (org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore)1