use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.
the class ConcurrentDOMDataBrokerTest method testLazySubTransactionCreationForReadOnlyTransactions.
@Test
public void testLazySubTransactionCreationForReadOnlyTransactions() {
DOMStore configDomStore = mock(DOMStore.class);
DOMStore operationalDomStore = mock(DOMStore.class);
DOMStoreReadTransaction storeTxn = mock(DOMStoreReadTransaction.class);
doReturn(storeTxn).when(operationalDomStore).newReadOnlyTransaction();
doReturn(storeTxn).when(configDomStore).newReadOnlyTransaction();
try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, operationalDomStore, LogicalDatastoreType.CONFIGURATION, configDomStore), futureExecutor)) {
DOMDataTreeReadTransaction dataTxn = dataBroker.newReadOnlyTransaction();
dataTxn.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
dataTxn.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
verify(configDomStore, never()).newReadOnlyTransaction();
verify(operationalDomStore, times(1)).newReadOnlyTransaction();
dataTxn.read(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
verify(configDomStore, times(1)).newReadOnlyTransaction();
verify(operationalDomStore, times(1)).newReadOnlyTransaction();
}
}
use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.
the class ConcurrentDOMDataBrokerTest method testSubmitWithOnlyOneSubTransaction.
@Test
public void testSubmitWithOnlyOneSubTransaction() throws InterruptedException {
DOMStore configDomStore = mock(DOMStore.class);
DOMStore operationalDomStore = mock(DOMStore.class);
DOMStoreReadWriteTransaction mockStoreReadWriteTransaction = mock(DOMStoreReadWriteTransaction.class);
DOMStoreThreePhaseCommitCohort mockCohort = mock(DOMStoreThreePhaseCommitCohort.class);
doReturn(mockStoreReadWriteTransaction).when(operationalDomStore).newReadWriteTransaction();
doReturn(mockCohort).when(mockStoreReadWriteTransaction).ready();
doReturn(Futures.immediateFuture(false)).when(mockCohort).canCommit();
doReturn(Futures.immediateFuture(null)).when(mockCohort).abort();
final CountDownLatch latch = new CountDownLatch(1);
final List<DOMStoreThreePhaseCommitCohort> commitCohorts = new ArrayList<>();
try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, operationalDomStore, LogicalDatastoreType.CONFIGURATION, configDomStore), futureExecutor) {
@Override
public CheckedFuture<Void, TransactionCommitFailedException> submit(DOMDataTreeWriteTransaction writeTx, Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
commitCohorts.addAll(cohorts);
latch.countDown();
return super.submit(writeTx, cohorts);
}
}) {
DOMDataTreeReadWriteTransaction domDataReadWriteTransaction = dataBroker.newReadWriteTransaction();
domDataReadWriteTransaction.delete(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY);
domDataReadWriteTransaction.submit();
assertTrue(latch.await(10, TimeUnit.SECONDS));
assertTrue(commitCohorts.size() == 1);
}
}
use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.
the class ConcurrentDOMDataBrokerTest method testLazySubTransactionCreationForWriteOnlyTransactions.
@Test
public void testLazySubTransactionCreationForWriteOnlyTransactions() {
DOMStore configDomStore = mock(DOMStore.class);
DOMStore operationalDomStore = mock(DOMStore.class);
DOMStoreWriteTransaction storeTxn = mock(DOMStoreWriteTransaction.class);
doReturn(storeTxn).when(operationalDomStore).newWriteOnlyTransaction();
doReturn(storeTxn).when(configDomStore).newWriteOnlyTransaction();
try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, operationalDomStore, LogicalDatastoreType.CONFIGURATION, configDomStore), futureExecutor)) {
DOMDataTreeWriteTransaction dataTxn = dataBroker.newWriteOnlyTransaction();
dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
dataTxn.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
verify(configDomStore, never()).newWriteOnlyTransaction();
verify(operationalDomStore, times(1)).newWriteOnlyTransaction();
dataTxn.put(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
verify(configDomStore, times(1)).newWriteOnlyTransaction();
verify(operationalDomStore, times(1)).newWriteOnlyTransaction();
}
}
use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.
the class ConcurrentDOMDataBrokerTest method testCreateWriteOnlyTransaction.
@Test
public void testCreateWriteOnlyTransaction() {
DOMStore domStore = mock(DOMStore.class);
try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor)) {
dataBroker.newWriteOnlyTransaction();
verify(domStore, never()).newWriteOnlyTransaction();
}
}
use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.
the class ConcurrentDOMDataBrokerTest method testCreateReadOnlyTransaction.
@Test
public void testCreateReadOnlyTransaction() {
DOMStore domStore = mock(DOMStore.class);
try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor)) {
dataBroker.newReadOnlyTransaction();
verify(domStore, never()).newReadOnlyTransaction();
}
}
Aggregations