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%2Fraft%2Fbehaviors%2FRaftActorBehavior.java;h=6b51c34e88ed6143e6c2e7a8c5c156266f83680f;hp=b766e0ce39fe9be1b847f54c625c802d036a7a0a;hb=1b0f84c4957e464bad6f7cb7350a8171c3d1621b;hpb=6dfafe7c19c5e79bce2cb8aa2470b23360c08147 diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/RaftActorBehavior.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/RaftActorBehavior.java index b766e0ce39..6b51c34e88 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/RaftActorBehavior.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/RaftActorBehavior.java @@ -9,22 +9,14 @@ package org.opendaylight.controller.cluster.raft.behaviors; import akka.actor.ActorRef; +import javax.annotation.Nullable; import org.opendaylight.controller.cluster.raft.RaftState; /** - * A RaftActorBehavior represents the specific behavior of a RaftActor - *

- * A RaftActor can behave as one of the following, - *

- *

- * In each of these behaviors the Raft Actor handles the same Raft messages - * differently. + * The interface for a class that implements a specific behavior of a RaftActor. The types of behaviors are enumerated + * by {@link RaftState}. Each handles the same Raft messages differently. */ -public interface RaftActorBehavior extends AutoCloseable{ +public interface RaftActorBehavior extends AutoCloseable { /** * Handle a message. If the processing of the message warrants a state @@ -34,32 +26,55 @@ public interface RaftActorBehavior extends AutoCloseable{ * @param sender The sender of the message * @param message A message that needs to be processed * - * @return The new behavior or current behavior + * @return The new behavior or current behavior, or null if the message was not handled. */ + @Nullable RaftActorBehavior handleMessage(ActorRef sender, Object message); /** - * The state associated with a given behavior + * Returns the state associated with this behavior. * - * @return + * @return the RaftState */ RaftState state(); /** + * Returns the id of the leader. * - * @return + * @return the id of the leader or null if not known */ + @Nullable String getLeaderId(); /** - * setting the index of the log entry which is replicated to all nodes - * @param replicatedToAllIndex + * Sets the index of the last log entry that has been replicated to all peers. + * + * @param replicatedToAllIndex the index */ void setReplicatedToAllIndex(long replicatedToAllIndex); /** - * getting the index of the log entry which is replicated to all nodes - * @return + * Returns the index of the last log entry that has been replicated to all peers. + * + * @return the index or -1 if not known */ long getReplicatedToAllIndex(); + + /** + * Returns the leader's payload data version. + * + * @return a short representing the version + */ + short getLeaderPayloadVersion(); + + /** + * Closes the current behavior and switches to the specified behavior, if possible. + * + * @param behavior the new behavior to switch to + * @return the new behavior + */ + RaftActorBehavior switchBehavior(RaftActorBehavior behavior); + + @Override + void close(); }