use of org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction in project controller by opendaylight.
the class DOMForwardedWriteTransaction method submit.
@Override
@SuppressWarnings("checkstyle:illegalcatch")
public CheckedFuture<Void, TransactionCommitFailedException> submit() {
final AbstractDOMForwardedTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
checkRunning(impl);
final Collection<T> txns = getSubtransactions();
final Collection<DOMStoreThreePhaseCommitCohort> cohorts = new ArrayList<>(txns.size());
CheckedFuture<Void, TransactionCommitFailedException> ret;
try {
for (DOMStoreWriteTransaction txn : txns) {
cohorts.add(txn.ready());
}
ret = impl.submit(this, cohorts);
} catch (RuntimeException e) {
ret = Futures.immediateFailedCheckedFuture(TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER.apply(e));
}
FUTURE_UPDATER.lazySet(this, ret);
return ret;
}
use of org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction in project controller by opendaylight.
the class InMemoryDataStoreTest method testReadyWithMissingMandatoryData.
@Test
public void testReadyWithMissingMandatoryData() throws InterruptedException {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
NormalizedNode<?, ?> testNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.MANDATORY_DATA_TEST_QNAME)).addChild(ImmutableNodes.leafNode(TestModel.OPTIONAL_QNAME, "data")).build();
writeTx.write(TestModel.MANDATORY_DATA_TEST_PATH, testNode);
DOMStoreThreePhaseCommitCohort ready = writeTx.ready();
try {
ready.canCommit().get();
Assert.fail("Expected exception on canCommit");
} catch (ExecutionException e) {
// nop
}
}
use of org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction in project controller by opendaylight.
the class InMemoryDataStoreTest method testWriteWithTransactionReady.
@Test(expected = IllegalStateException.class)
public void testWriteWithTransactionReady() throws Exception {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
writeTx.ready();
// Should throw ex
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
}
use of org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction in project controller by opendaylight.
the class InMemoryDataStoreTest method testReadyWithTransactionAlreadyReady.
@Test(expected = IllegalStateException.class)
public void testReadyWithTransactionAlreadyReady() throws Exception {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
writeTx.ready();
// Should throw ex
writeTx.ready();
}
use of org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction in project controller by opendaylight.
the class DeleteModificationTest method testApply.
@Test
public void testApply() throws Exception {
// Write something into the datastore
DOMStoreReadWriteTransaction writeTransaction = store.newReadWriteTransaction();
WriteModification writeModification = new WriteModification(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
writeModification.apply(writeTransaction);
commitTransaction(writeTransaction);
// Check if it's in the datastore
Optional<NormalizedNode<?, ?>> data = readData(TestModel.TEST_PATH);
Assert.assertTrue(data.isPresent());
// Delete stuff from the datastore
DOMStoreWriteTransaction deleteTransaction = store.newWriteOnlyTransaction();
DeleteModification deleteModification = new DeleteModification(TestModel.TEST_PATH);
deleteModification.apply(deleteTransaction);
commitTransaction(deleteTransaction);
data = readData(TestModel.TEST_PATH);
Assert.assertFalse(data.isPresent());
}
Aggregations