use of org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.Commit in project controller by opendaylight.
the class DataTreeCohortActorTest method testAsyncCohort.
@SuppressWarnings("unchecked")
@Test
public void testAsyncCohort() throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
doReturn(Futures.makeChecked(executeWithDelay(executor, mockPostCanCommit), ex -> new DataValidationFailedException(YangInstanceIdentifier.EMPTY, "mock"))).when(mockCohort).canCommit(any(Object.class), any(Collection.class), any(SchemaContext.class));
doReturn(JdkFutureAdapters.listenInPoolThread(executor.submit(() -> mockPostPreCommit), MoreExecutors.directExecutor())).when(mockPostCanCommit).preCommit();
doReturn(JdkFutureAdapters.listenInPoolThread(executor.submit(() -> null), MoreExecutors.directExecutor())).when(mockPostPreCommit).commit();
ActorRef cohortActor = newCohortActor("testAsyncCohort");
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 Commit(txId));
verify(mockPostPreCommit).commit();
executor.shutdownNow();
}
use of org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.Commit in project controller by opendaylight.
the class DataTreeCohortActorTest method testSuccessfulThreePhaseCommit.
@Test
public void testSuccessfulThreePhaseCommit() throws Exception {
ActorRef cohortActor = newCohortActor("testSuccessfulThreePhaseCommit");
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 Commit(txId));
verify(mockPostPreCommit).commit();
resetMockCohort();
askAndAwait(cohortActor, new CanCommit(txId, CANDIDATES, MOCK_SCHEMA, cohortActor));
verify(mockCohort).canCommit(txId, CANDIDATES, MOCK_SCHEMA);
}
use of org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.Commit in project controller by opendaylight.
the class DataTreeCohortActorTest method testMultipleThreePhaseCommits.
@Test
public void testMultipleThreePhaseCommits() throws Exception {
ActorRef cohortActor = newCohortActor("testMultipleThreePhaseCommits");
TransactionIdentifier txId1 = nextTransactionId();
TransactionIdentifier txId2 = nextTransactionId();
askAndAwait(cohortActor, new CanCommit(txId1, CANDIDATES, MOCK_SCHEMA, cohortActor));
askAndAwait(cohortActor, new CanCommit(txId2, CANDIDATES, MOCK_SCHEMA, cohortActor));
askAndAwait(cohortActor, new PreCommit(txId1));
askAndAwait(cohortActor, new PreCommit(txId2));
askAndAwait(cohortActor, new Commit(txId1));
askAndAwait(cohortActor, new Commit(txId2));
}
Aggregations