2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.raft;
10 import javax.annotation.Nonnull;
11 import javax.annotation.Nullable;
12 import org.opendaylight.controller.cluster.raft.behaviors.LeaderInstallSnapshotState;
15 * The state of the followers log as known by the Leader
17 public interface FollowerLogInformation {
20 * Increment the value of the nextIndex
22 * @return the new value of nextIndex
27 * Decrement the value of the nextIndex
29 * @return the new value of nextIndex
34 * Sets the index of the next log entry for this follower.
37 * @return true if the new index differed from the current index and the current index was updated, false
40 boolean setNextIndex(long nextIndex);
43 * Increment the value of the matchIndex
45 * @return the new value of matchIndex
47 long incrMatchIndex();
50 * Sets the index of the highest log entry for this follower.
53 * @return true if the new index differed from the current index and the current index was updated, false
56 boolean setMatchIndex(long matchIndex);
60 * @return the identifier of the follower. This could simply be the url of the remote actor.
65 * @return index of the next log entry to send to that server (initialized to leader last log index + 1)
70 * @return index of highest log entry known to be replicated on server (initialized to 0, increases monotonically)
75 * Checks if the follower is active by comparing the last updated with the duration
77 * @return true if follower is active, false otherwise
79 boolean isFollowerActive();
82 * restarts the timeout clock of the follower
84 void markFollowerActive();
87 * This will stop the timeout clock
89 void markFollowerInActive();
93 * This will return the active time of follower, since it was last reset
95 * @return time in milliseconds since the last activity from the follower
97 long timeSinceLastActivity();
100 * This method checks if it is ok to replicate
102 * @return true if it is ok to replicate, false otherwise
104 boolean okToReplicate();
107 * @return the payload data version of the follower.
109 short getPayloadVersion();
112 * Sets the payload data version of the follower.
114 void setPayloadVersion(short payloadVersion);
117 * @return the raft version of the follower.
119 short getRaftVersion();
122 * Sets the raft version of the follower.
124 void setRaftVersion(short payloadVersion);
127 * Returns the LeaderInstallSnapshotState for the in progress install snapshot.
129 * @return the LeaderInstallSnapshotState if a snapshot install is in progress, null otherwise.
132 LeaderInstallSnapshotState getInstallSnapshotState();
135 * Sets the LeaderInstallSnapshotState when an install snapshot is initiated.
137 * @param state the LeaderInstallSnapshotState
139 void setLeaderInstallSnapshotState(@Nonnull LeaderInstallSnapshotState state);
142 * Clears the LeaderInstallSnapshotState when an install snapshot is complete.
144 void clearLeaderInstallSnapshotState();