import org.opendaylight.controller.cluster.datastore.utils.PrimaryShardInfoFutureCache;
import org.opendaylight.controller.cluster.raft.TestActorFactory;
import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
-import org.opendaylight.controller.protobuff.messages.cohort3pc.ThreePhaseCommitCohortMessages;
public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest {
verifyCohortActors();
}
- @Test
- public void testBackwardsCompatibilityWithPreBoron() throws Exception {
- List<CohortInfo> cohorts = Arrays.asList(
- newCohortInfo(new CohortActor.Builder("txn-1").
- expectCanCommit(ThreePhaseCommitCohortMessages.CanCommitTransaction.class,
- CanCommitTransactionReply.yes(DataStoreVersions.LITHIUM_VERSION)).
- expectCommit(ThreePhaseCommitCohortMessages.CommitTransaction.class,
- CommitTransactionReply.instance(DataStoreVersions.LITHIUM_VERSION)),
- DataStoreVersions.LITHIUM_VERSION));
- ThreePhaseCommitCohortProxy proxy = new ThreePhaseCommitCohortProxy(actorContext, cohorts, "txn-1");
-
- verifyCanCommit(proxy.canCommit(), true);
- verifySuccessfulFuture(proxy.preCommit());
- verifySuccessfulFuture(proxy.commit());
- verifyCohortActors();
- }
-
private void propagateExecutionExceptionCause(ListenableFuture<?> future) throws Throwable {
try {
});
}
- private CohortInfo newCohortInfoWithFailedFuture(Exception failure) {
+ private static CohortInfo newCohortInfoWithFailedFuture(Exception failure) {
return new CohortInfo(Futures.<ActorSelection>failed(failure), new Supplier<Short>() {
@Override
public Short get() {
@Override
public void onReceive(Object message) {
if(CanCommitTransaction.isSerializedType(message)) {
+ canCommitCount.incrementAndGet();
onMessage("CanCommitTransaction", message, CanCommitTransaction.fromSerializable(message),
builder.expCanCommitType, builder.canCommitReply);
- canCommitCount.incrementAndGet();
} else if(CommitTransaction.isSerializedType(message)) {
+ commitCount.incrementAndGet();
onMessage("CommitTransaction", message, CommitTransaction.fromSerializable(message),
builder.expCommitType, builder.commitReply);
- commitCount.incrementAndGet();
} else if(AbortTransaction.isSerializedType(message)) {
+ abortCount.incrementAndGet();
onMessage("AbortTransaction", message, AbortTransaction.fromSerializable(message),
builder.expAbortType, builder.abortReply);
- abortCount.incrementAndGet();
} else {
assertionError = new AssertionError("Unexpected message " + message);
}