X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fexample%2FExampleActor.java;h=77eaac2cfef076fd84959d0e9007fe6233413c9d;hp=ed19f21dedb8d5900a0df35aa31fc20ce6b8aee4;hb=c31a6fcf9fb070d4419ca4c32d8b531fdcb5030d;hpb=8eaba1eb027b02f8b36480721055dc99c6700e85 diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java index ed19f21ded..77eaac2cfe 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/example/ExampleActor.java @@ -19,6 +19,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.HashMap; import java.util.Map; +import javax.annotation.Nonnull; import org.opendaylight.controller.cluster.example.messages.KeyValue; import org.opendaylight.controller.cluster.example.messages.KeyValueSaved; import org.opendaylight.controller.cluster.example.messages.PrintRole; @@ -26,6 +27,8 @@ import org.opendaylight.controller.cluster.example.messages.PrintState; import org.opendaylight.controller.cluster.notifications.RoleChangeNotifier; import org.opendaylight.controller.cluster.raft.ConfigParams; import org.opendaylight.controller.cluster.raft.RaftActor; +import org.opendaylight.controller.cluster.raft.RaftActorRecoveryCohort; +import org.opendaylight.controller.cluster.raft.RaftActorSnapshotCohort; import org.opendaylight.controller.cluster.raft.RaftState; import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply; import org.opendaylight.controller.cluster.raft.behaviors.Leader; @@ -34,7 +37,7 @@ import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payloa /** * A sample actor showing how the RaftActor is to be extended */ -public class ExampleActor extends RaftActor { +public class ExampleActor extends RaftActor implements RaftActorRecoveryCohort, RaftActorSnapshotCohort { private final Map state = new HashMap(); @@ -118,7 +121,8 @@ public class ExampleActor extends RaftActor { } } - @Override protected void createSnapshot() { + @Override + public void createSnapshot(ActorRef actorRef) { ByteString bs = null; try { bs = fromObject(state); @@ -128,7 +132,8 @@ public class ExampleActor extends RaftActor { getSelf().tell(new CaptureSnapshotReply(bs.toByteArray()), null); } - @Override protected void applySnapshot(byte [] snapshot) { + @Override + public void applySnapshot(byte [] snapshot) { state.clear(); try { state.putAll((HashMap) toObject(snapshot)); @@ -192,22 +197,33 @@ public class ExampleActor extends RaftActor { } @Override - protected void startLogRecoveryBatch(int maxBatchSize) { + @Nonnull + protected RaftActorRecoveryCohort getRaftActorRecoveryCohort() { + return this; + } + + @Override + public void startLogRecoveryBatch(int maxBatchSize) { + } + + @Override + public void appendRecoveredLogEntry(Payload data) { } @Override - protected void appendRecoveredLogEntry(Payload data) { + public void applyCurrentLogRecoveryBatch() { } @Override - protected void applyCurrentLogRecoveryBatch() { + public void onRecoveryComplete() { } @Override - protected void onRecoveryComplete() { + public void applyRecoverySnapshot(byte[] snapshot) { } @Override - protected void applyRecoverySnapshot(byte[] snapshot) { + protected RaftActorSnapshotCohort getRaftActorSnapshotCohort() { + return this; } }