Search in sources :

Example 56 with TransactionIdentifier

use of org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier in project controller by opendaylight.

the class DataTreeCohortActorTest method testAbortAfterPreCommit.

@Test
public void testAbortAfterPreCommit() throws Exception {
    ActorRef cohortActor = newCohortActor("testAbortAfterPreCommit");
    TransactionIdentifier txId = nextTransactionId();
    askAndAwait(cohortActor, new CanCommit(txId, CANDIDATES, MOCK_SCHEMA, cohortActor));
    verify(mockCohort).canCommit(txId, CANDIDATES, MOCK_SCHEMA);
    askAndAwait(cohortActor, new PreCommit(txId));
    verify(mockPostCanCommit).preCommit();
    askAndAwait(cohortActor, new Abort(txId));
    verify(mockPostPreCommit).abort();
}
Also used : Abort(org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.Abort) ActorRef(akka.actor.ActorRef) TransactionIdentifier(org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier) PreCommit(org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.PreCommit) CanCommit(org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.CanCommit) Test(org.junit.Test)

Example 57 with TransactionIdentifier

use of org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier in project controller by opendaylight.

the class AbstractShardTest method setupCohortDecorator.

protected Map<TransactionIdentifier, CapturingShardDataTreeCohort> setupCohortDecorator(final Shard shard, final TransactionIdentifier... transactionIDs) {
    final Map<TransactionIdentifier, CapturingShardDataTreeCohort> cohortMap = new HashMap<>();
    for (TransactionIdentifier id : transactionIDs) {
        cohortMap.put(id, new CapturingShardDataTreeCohort());
    }
    shard.getCommitCoordinator().setCohortDecorator((transactionID, actual) -> {
        CapturingShardDataTreeCohort cohort = cohortMap.get(transactionID);
        cohort.setDelegate(actual);
        return cohort;
    });
    return cohortMap;
}
Also used : HashMap(java.util.HashMap) TransactionIdentifier(org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)

Aggregations

TransactionIdentifier (org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)57 Test (org.junit.Test)37 FiniteDuration (scala.concurrent.duration.FiniteDuration)17 CanCommitTransaction (org.opendaylight.controller.cluster.datastore.messages.CanCommitTransaction)16 CommitTransaction (org.opendaylight.controller.cluster.datastore.messages.CommitTransaction)12 DataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification)11 CanCommitTransactionReply (org.opendaylight.controller.cluster.datastore.messages.CanCommitTransactionReply)10 ActorRef (akka.actor.ActorRef)8 FollowerInitialSyncUpStatus (org.opendaylight.controller.cluster.raft.base.messages.FollowerInitialSyncUpStatus)8 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)8 BatchedModifications (org.opendaylight.controller.cluster.datastore.messages.BatchedModifications)7 WriteModification (org.opendaylight.controller.cluster.datastore.modification.WriteModification)7 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)7 DataTree (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree)7 LocalHistoryIdentifier (org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier)6 CanCommit (org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.CanCommit)6 Failure (akka.actor.Status.Failure)5 Timeout (akka.util.Timeout)5 Response (org.opendaylight.controller.cluster.access.concepts.Response)5 ReadyLocalTransaction (org.opendaylight.controller.cluster.datastore.messages.ReadyLocalTransaction)5