X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FThreePhaseCommitCohort.java;h=a8deb0153a400eefbf28fd4269892c86ea61ef35;hb=eb887b1c2c8cd2768f8b4c2ed2b5054f97798466;hp=00d4ab5782e3e7f0a365bdd9ace5be917b423dc1;hpb=c3140359f8fc9759a309cb2d0476df5609952894;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohort.java index 00d4ab5782..a8deb0153a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohort.java @@ -9,8 +9,8 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorRef; +import akka.actor.PoisonPill; import akka.actor.Props; -import akka.actor.UntypedActor; import akka.event.Logging; import akka.event.LoggingAdapter; import akka.japi.Creator; @@ -28,7 +28,7 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCoh import java.util.concurrent.ExecutionException; -public class ThreePhaseCommitCohort extends UntypedActor { +public class ThreePhaseCommitCohort extends AbstractUntypedActor { private final DOMStoreThreePhaseCommitCohort cohort; private final ActorRef shardActor; private final CompositeModification modification; @@ -55,18 +55,19 @@ public class ThreePhaseCommitCohort extends UntypedActor { }); } + @Override - public void onReceive(Object message) throws Exception { - log.debug("Received message {}", message); - - if (message instanceof CanCommitTransaction) { - canCommit((CanCommitTransaction) message); - } else if (message instanceof PreCommitTransaction) { - preCommit((PreCommitTransaction) message); - } else if (message instanceof CommitTransaction) { - commit((CommitTransaction) message); - } else if (message instanceof AbortTransaction) { - abort((AbortTransaction) message); + public void handleReceive(Object message) throws Exception { + if (message.getClass().equals(CanCommitTransaction.SERIALIZABLE_CLASS)) { + canCommit(new CanCommitTransaction()); + } else if (message.getClass().equals(PreCommitTransaction.SERIALIZABLE_CLASS)) { + preCommit(new PreCommitTransaction()); + } else if (message.getClass().equals(CommitTransaction.SERIALIZABLE_CLASS)) { + commit(new CommitTransaction()); + } else if (message.getClass().equals(AbortTransaction.SERIALIZABLE_CLASS)) { + abort(new AbortTransaction()); + } else { + throw new Exception ("Not recognized message received,message="+message); } } @@ -80,7 +81,7 @@ public class ThreePhaseCommitCohort extends UntypedActor { public void run() { try { future.get(); - sender.tell(new AbortTransactionReply(), self); + sender.tell(new AbortTransactionReply().toSerializable(), self); } catch (InterruptedException | ExecutionException e) { log.error(e, "An exception happened when aborting"); } @@ -94,6 +95,8 @@ public class ThreePhaseCommitCohort extends UntypedActor { shardActor.forward(new ForwardedCommitTransaction(cohort, modification), getContext()); + getContext().parent().tell(PoisonPill.getInstance(), getSelf()); + } private void preCommit(PreCommitTransaction message) { @@ -106,7 +109,7 @@ public class ThreePhaseCommitCohort extends UntypedActor { public void run() { try { future.get(); - sender.tell(new PreCommitTransactionReply(), self); + sender.tell(new PreCommitTransactionReply().toSerializable(), self); } catch (InterruptedException | ExecutionException e) { log.error(e, "An exception happened when preCommitting"); } @@ -125,7 +128,7 @@ public class ThreePhaseCommitCohort extends UntypedActor { public void run() { try { Boolean canCommit = future.get(); - sender.tell(new CanCommitTransactionReply(canCommit), self); + sender.tell(new CanCommitTransactionReply(canCommit).toSerializable(), self); } catch (InterruptedException | ExecutionException e) { log.error(e, "An exception happened when aborting"); }