use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.
the class AbstractDOMBroker method getDOMStore.
private DOMStore getDOMStore(final LogicalDatastoreType type) {
DOMStore store = getTxFactories().get(type);
checkState(store != null, "Requested logical data store is not available.");
return store;
}
use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.
the class ConcurrentDOMDataBrokerTest method testCreateTransactionOnChain.
@Test
public void testCreateTransactionOnChain() {
DOMStore domStore = mock(DOMStore.class);
try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor)) {
DOMStoreReadWriteTransaction operationalTransaction = mock(DOMStoreReadWriteTransaction.class);
DOMStoreTransactionChain mockChain = mock(DOMStoreTransactionChain.class);
doReturn(mockChain).when(domStore).createTransactionChain();
doReturn(operationalTransaction).when(mockChain).newWriteOnlyTransaction();
DOMTransactionChain transactionChain = dataBroker.createTransactionChain(mock(TransactionChainListener.class));
DOMDataTreeWriteTransaction domDataWriteTransaction = transactionChain.newWriteOnlyTransaction();
verify(mockChain, never()).newWriteOnlyTransaction();
domDataWriteTransaction.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
}
}
use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.
the class ConcurrentDOMDataBrokerTest method testEmptyTransactionSubmitSucceeds.
@Test
public void testEmptyTransactionSubmitSucceeds() throws ExecutionException, InterruptedException {
DOMStore domStore = mock(DOMStore.class);
try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor)) {
CheckedFuture<Void, TransactionCommitFailedException> submit1 = dataBroker.newWriteOnlyTransaction().submit();
assertNotNull(submit1);
submit1.get();
CheckedFuture<Void, TransactionCommitFailedException> submit2 = dataBroker.newReadWriteTransaction().submit();
assertNotNull(submit2);
submit2.get();
}
}
use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.
the class ConcurrentDOMDataBrokerTest method testCreateReadWriteTransaction.
@Test
public void testCreateReadWriteTransaction() {
DOMStore domStore = mock(DOMStore.class);
try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, domStore, LogicalDatastoreType.CONFIGURATION, domStore), futureExecutor)) {
dataBroker.newReadWriteTransaction();
verify(domStore, never()).newReadWriteTransaction();
}
}
use of org.opendaylight.mdsal.dom.spi.store.DOMStore in project controller by opendaylight.
the class ConcurrentDOMDataBrokerTest method testSubmitWithOnlyTwoSubTransactions.
@Test
public void testSubmitWithOnlyTwoSubTransactions() throws InterruptedException {
DOMStore configDomStore = mock(DOMStore.class);
DOMStore operationalDomStore = mock(DOMStore.class);
DOMStoreReadWriteTransaction operationalTransaction = mock(DOMStoreReadWriteTransaction.class);
DOMStoreReadWriteTransaction configTransaction = mock(DOMStoreReadWriteTransaction.class);
DOMStoreThreePhaseCommitCohort mockCohortOperational = mock(DOMStoreThreePhaseCommitCohort.class);
DOMStoreThreePhaseCommitCohort mockCohortConfig = mock(DOMStoreThreePhaseCommitCohort.class);
doReturn(operationalTransaction).when(operationalDomStore).newReadWriteTransaction();
doReturn(configTransaction).when(configDomStore).newReadWriteTransaction();
doReturn(mockCohortOperational).when(operationalTransaction).ready();
doReturn(Futures.immediateFuture(false)).when(mockCohortOperational).canCommit();
doReturn(Futures.immediateFuture(null)).when(mockCohortOperational).abort();
doReturn(mockCohortConfig).when(configTransaction).ready();
doReturn(Futures.immediateFuture(false)).when(mockCohortConfig).canCommit();
doReturn(Futures.immediateFuture(null)).when(mockCohortConfig).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
@SuppressWarnings("checkstyle:hiddenField")
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.put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
domDataReadWriteTransaction.merge(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY, mock(NormalizedNode.class));
domDataReadWriteTransaction.submit();
assertTrue(latch.await(10, TimeUnit.SECONDS));
assertTrue(commitCohorts.size() == 2);
}
}
Aggregations