Bug 6540: Move LeaderInstallSnapshotState to FollowerLogInformation
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / FollowerLogInformation.java
index 07b6b617aaa862b472fb479be247479e1096f434..c0855c7f71835971f0cd81ffd70430dbeecb5a0c 100644 (file)
@@ -7,6 +7,10 @@
  */
 package org.opendaylight.controller.cluster.raft;
 
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.controller.cluster.raft.behaviors.LeaderInstallSnapshotState;
+
 /**
  * The state of the followers log as known by the Leader
  */
@@ -14,13 +18,15 @@ public interface FollowerLogInformation {
 
     /**
      * Increment the value of the nextIndex
-     * @return
+     *
+     * @return the new value of nextIndex
      */
     long incrNextIndex();
 
     /**
      * Decrement the value of the nextIndex
-     * @return
+     *
+     * @return the new value of nextIndex
      */
     long decrNextIndex();
 
@@ -35,7 +41,8 @@ public interface FollowerLogInformation {
 
     /**
      * Increment the value of the matchIndex
-     * @return
+     *
+     * @return the new value of matchIndex
      */
     long incrMatchIndex();
 
@@ -49,28 +56,25 @@ public interface FollowerLogInformation {
     boolean setMatchIndex(long matchIndex);
 
     /**
-     * The identifier of the follower
-     * This could simply be the url of the remote actor
+     *
+     * @return the identifier of the follower. This could simply be the url of the remote actor.
      */
     String getId();
 
     /**
-     * for each server, index of the next log entry
-     * to send to that server (initialized to leader
-     *    last log index + 1)
+     * @return index of the next log entry to send to that server (initialized to leader last log index + 1)
      */
     long getNextIndex();
 
     /**
-     * for each server, index of highest log entry
-     * known to be replicated on server
-     *    (initialized to 0, increases monotonically)
+     * @return index of highest log entry known to be replicated on server (initialized to 0, increases monotonically)
      */
     long getMatchIndex();
 
     /**
      * Checks if the follower is active by comparing the last updated with the duration
-     * @return boolean
+     *
+     * @return true if follower is active, false otherwise
      */
     boolean isFollowerActive();
 
@@ -87,14 +91,55 @@ public interface FollowerLogInformation {
 
     /**
      * This will return the active time of follower, since it was last reset
-     * @return time in milliseconds
+     *
+     * @return time in milliseconds since the last activity from the follower
      */
     long timeSinceLastActivity();
 
     /**
      * This method checks if it is ok to replicate
      *
-     * @return true if it is ok to replicate
+     * @return true if it is ok to replicate, false otherwise
      */
     boolean okToReplicate();
+
+    /**
+     * @return the payload data version of the follower.
+     */
+    short getPayloadVersion();
+
+    /**
+     * Sets the payload data version of the follower.
+     */
+    void setPayloadVersion(short payloadVersion);
+
+    /**
+     * @return the raft version of the follower.
+     */
+    short getRaftVersion();
+
+    /**
+     * Sets the raft version of the follower.
+     */
+    void setRaftVersion(short payloadVersion);
+
+    /**
+     * Returns the LeaderInstallSnapshotState for the in progress install snapshot.
+     *
+     * @return the LeaderInstallSnapshotState if a snapshot install is in progress, null otherwise.
+     */
+    @Nullable
+    LeaderInstallSnapshotState getInstallSnapshotState();
+
+    /**
+     * Sets the LeaderInstallSnapshotState when an install snapshot is initiated.
+     *
+     * @param state the LeaderInstallSnapshotState
+     */
+    void setLeaderInstallSnapshotState(@Nonnull LeaderInstallSnapshotState state);
+
+    /**
+     * Clears the LeaderInstallSnapshotState when an install snapshot is complete.
+     */
+    void clearLeaderInstallSnapshotState();
 }