use of org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction in project controller by opendaylight.
the class ShardedDOMDataBrokerDelegatingTransactionChainTest method testNewReadWriteTransaction.
@Test
public void testNewReadWriteTransaction() {
DOMDataTreeReadTransaction delegateReadTx = mock(DOMDataTreeReadTransaction.class);
doReturn("TEST-READ-TX-DELEGATE").when(delegateReadTx).getIdentifier();
doReturn(delegateReadTx).when(delegateTxChain).newReadOnlyTransaction();
DOMDataTreeWriteTransaction delegateWriteTx = mock(DOMDataTreeWriteTransaction.class);
doReturn(delegateWriteTx).when(delegateTxChain).newWriteOnlyTransaction();
doReturn("TEST-WRITE-TX-DELEGATE").when(delegateWriteTx).getIdentifier();
txChain.newReadWriteTransaction();
verify(delegateTxChain).newReadOnlyTransaction();
verify(delegateTxChain).newWriteOnlyTransaction();
}
use of org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction in project controller by opendaylight.
the class ShardedDOMDataBrokerDelegatingTransactionChain method newReadWriteTransaction.
@Override
public DOMDataReadWriteTransaction newReadWriteTransaction() {
final Object readWriteTxId = newTransactionIdentifier();
final DOMDataTreeReadTransaction readTxDelegate = txChainDelegate.newReadOnlyTransaction();
final DOMDataReadOnlyTransaction readTx = new ShardedDOMDataBrokerDelegatingReadTransaction(readWriteTxId, readTxDelegate);
final DOMDataTreeWriteTransaction writeTxDelegate = txChainDelegate.newWriteOnlyTransaction();
final DOMDataWriteTransaction writeTx = new ShardedDOMDataBrokerDelegatingWriteTransaction(readWriteTxId, writeTxDelegate);
final DOMDataReadWriteTransaction readWriteTx = new ShardedDOMDataBrokerDelegatingReadWriteTransaction(readWriteTxId, schemaContext, readTx, writeTx);
transactionMap.put(readTxDelegate.getIdentifier(), readWriteTx);
transactionMap.put(writeTxDelegate.getIdentifier(), readWriteTx);
return readWriteTx;
}
use of org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction in project controller by opendaylight.
the class DistributedDataStoreIntegrationTest method testChainedTransactionFailureWithMultipleShards.
@Test
public void testChainedTransactionFailureWithMultipleShards() throws Exception {
new IntegrationTestKit(getSystem(), datastoreContextBuilder) {
{
try (AbstractDataStore dataStore = setupAbstractDataStore(testParameter, "testChainedTransactionFailureWithMultipleShards", "cars-1", "people-1")) {
final ConcurrentDOMDataBroker broker = new ConcurrentDOMDataBroker(ImmutableMap.<LogicalDatastoreType, DOMStore>builder().put(LogicalDatastoreType.CONFIGURATION, dataStore).build(), MoreExecutors.directExecutor());
final TransactionChainListener listener = Mockito.mock(TransactionChainListener.class);
final DOMTransactionChain txChain = broker.createTransactionChain(listener);
final DOMDataTreeWriteTransaction writeTx = txChain.newReadWriteTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, PeopleModel.BASE_PATH, PeopleModel.emptyContainer());
final ContainerNode invalidData = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CarsModel.BASE_QNAME)).withChild(ImmutableNodes.leafNode(TestModel.JUNK_QNAME, "junk")).build();
writeTx.merge(LogicalDatastoreType.CONFIGURATION, CarsModel.BASE_PATH, invalidData);
// done for put for performance reasons.
try {
writeTx.submit().checkedGet(5, TimeUnit.SECONDS);
fail("Expected TransactionCommitFailedException");
} catch (final TransactionCommitFailedException e) {
// Expected
}
verify(listener, timeout(5000)).onTransactionChainFailed(eq(txChain), eq(writeTx), any(Throwable.class));
txChain.close();
broker.close();
}
}
};
}
Aggregations