use of org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort 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.DOMStoreThreePhaseCommitCohort in project controller by opendaylight.
the class CommitCoordinationTask method commitAll.
/**
* Invokes commit on underlying cohorts and returns future which
* completes
* once all commits on cohorts are completed.
*
* <p>
* Valid state transition is from PRE_COMMIT to COMMIT, if not throws
* IllegalStateException
*
* @return List of all cohorts futures from can commit phase.
*/
private ListenableFuture<?>[] commitAll() {
final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
int index = 0;
for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
ops[index++] = cohort.commit();
}
return ops;
}
use of org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort in project controller by opendaylight.
the class CommitCoordinationTask method preCommitAll.
/**
* Invokes preCommit on underlying cohorts and returns future
* which will complete once all preCommit on cohorts completed or
* failed.
*
* <p>
* Valid state transition is from CAN_COMMIT to PRE_COMMIT, if current
* state is not CAN_COMMIT
* throws IllegalStateException.
*
* @return List of all cohorts futures from can commit phase.
*/
private ListenableFuture<?>[] preCommitAll() {
final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
int index = 0;
for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
ops[index++] = cohort.preCommit();
}
return ops;
}
use of org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort in project controller by opendaylight.
the class AbstractModificationTest method commitTransaction.
protected void commitTransaction(final DOMStoreWriteTransaction transaction) {
DOMStoreThreePhaseCommitCohort cohort = transaction.ready();
cohort.preCommit();
cohort.commit();
}
use of org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort 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
}
}
Aggregations