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%2FFollowerLogInformation.java;h=c0855c7f71835971f0cd81ffd70430dbeecb5a0c;hp=f3de9835385eb0880bb567402f5bb493f8ad3a76;hb=95d3c7975a423951dcbdecfbfa4cb6b7a23591cc;hpb=11e9ade9af527aba7faeb633d3c9c7552fd09d2d diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformation.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformation.java index f3de983538..c0855c7f71 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformation.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformation.java @@ -5,10 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft; -import java.util.concurrent.atomic.AtomicLong; +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 @@ -17,49 +18,128 @@ public interface FollowerLogInformation { /** * Increment the value of the nextIndex - * @return + * + * @return the new value of nextIndex */ - public long incrNextIndex(); + long incrNextIndex(); /** * Decrement the value of the nextIndex - * @return + * + * @return the new value of nextIndex */ - public long decrNextIndex(); + long decrNextIndex(); /** + * Sets the index of the next log entry for this follower. * * @param nextIndex + * @return true if the new index differed from the current index and the current index was updated, false + * otherwise. */ - void setNextIndex(long nextIndex); + boolean setNextIndex(long nextIndex); /** * Increment the value of the matchIndex - * @return + * + * @return the new value of matchIndex + */ + long incrMatchIndex(); + + /** + * Sets the index of the highest log entry for this follower. + * + * @param matchIndex + * @return true if the new index differed from the current index and the current index was updated, false + * otherwise. + */ + boolean setMatchIndex(long matchIndex); + + /** + * + * @return the identifier of the follower. This could simply be the url of the remote actor. + */ + String getId(); + + /** + * @return index of the next log entry to send to that server (initialized to leader last log index + 1) + */ + long getNextIndex(); + + /** + * @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 true if follower is active, false otherwise + */ + boolean isFollowerActive(); + + /** + * restarts the timeout clock of the follower + */ + void markFollowerActive(); + + /** + * This will stop the timeout clock + */ + void markFollowerInActive(); + + + /** + * This will return the active time of follower, since it was last reset + * + * @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, false otherwise + */ + boolean okToReplicate(); + + /** + * @return the payload data version of the follower. */ - public long incrMatchIndex(); + short getPayloadVersion(); - public void setMatchIndex(long matchIndex); + /** + * Sets the payload data version of the follower. + */ + void setPayloadVersion(short payloadVersion); /** - * The identifier of the follower - * This could simply be the url of the remote actor + * @return the raft version of the follower. */ - public String getId(); + short getRaftVersion(); /** - * for each server, index of the next log entry - * to send to that server (initialized to leader - * last log index + 1) + * Sets the raft version of the follower. */ - public AtomicLong getNextIndex(); + void setRaftVersion(short payloadVersion); /** - * for each server, index of highest log entry - * known to be replicated on server - * (initialized to 0, increases monotonically) + * Returns the LeaderInstallSnapshotState for the in progress install snapshot. + * + * @return the LeaderInstallSnapshotState if a snapshot install is in progress, null otherwise. */ - public AtomicLong getMatchIndex(); + @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(); }