Remove unneeded SuppressWarnings
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / FollowerLogInformation.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.raft;
9
10 import com.google.common.annotations.VisibleForTesting;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import org.opendaylight.controller.cluster.raft.behaviors.LeaderInstallSnapshotState;
14
15 /**
16  * The state of the followers log as known by the Leader.
17  */
18 public interface FollowerLogInformation {
19
20     /**
21      * Increments the value of the follower's next index.
22      *
23      * @return the new value of nextIndex.
24      */
25     long incrNextIndex();
26
27     /**
28      * Decrements the value of the follower's next index.
29      *
30      * @return the new value of nextIndex,
31      */
32     long decrNextIndex();
33
34     /**
35      * Sets the index of the follower's next log entry.
36      *
37      * @param nextIndex the new index.
38      * @return true if the new index differed from the current index and the current index was updated, false
39      *              otherwise.
40      */
41     boolean setNextIndex(long nextIndex);
42
43     /**
44      * Increments the value of the follower's match index.
45      *
46      * @return the new value of matchIndex.
47      */
48     long incrMatchIndex();
49
50     /**
51      * Sets the index of the follower's highest log entry.
52      *
53      * @param matchIndex the new index.
54      * @return true if the new index differed from the current index and the current index was updated, false
55      *              otherwise.
56      */
57     boolean setMatchIndex(long matchIndex);
58
59     /**
60      * Returns the identifier of the follower.
61      *
62      * @return the identifier of the follower.
63      */
64     String getId();
65
66     /**
67      * Returns the index of the next log entry to send to the follower.
68      *
69      * @return index of the follower's next log entry.
70      */
71     long getNextIndex();
72
73     /**
74      * Returns the index of highest log entry known to be replicated on the follower.
75      *
76      * @return the index of highest log entry.
77      */
78     long getMatchIndex();
79
80     /**
81      * Checks if the follower is active by comparing the time of the last activity with the election time out. The
82      * follower is active if some activity has occurred for the follower within the election time out interval.
83      *
84      * @return true if follower is active, false otherwise.
85      */
86     boolean isFollowerActive();
87
88     /**
89      * Marks the follower as active. This should be called when some activity has occurred for the follower.
90      */
91     void markFollowerActive();
92
93     /**
94      * Marks the follower as inactive. This should only be called from unit tests.
95      */
96     @VisibleForTesting
97     void markFollowerInActive();
98
99
100     /**
101      * Returns the time since the last activity occurred for the follower.
102      *
103      * @return time in milliseconds since the last activity from the follower.
104      */
105     long timeSinceLastActivity();
106
107     /**
108      * This method checks if the next replicate message can be sent to the follower. This is an optimization to avoid
109      * sending duplicate message too frequently if the last replicate message was sent and no reply has been received
110      * yet within the current heart beat interval
111      *
112      * @return true if it is ok to replicate, false otherwise
113      */
114     boolean okToReplicate();
115
116     /**
117      * Returns the log entry payload data version of the follower.
118      *
119      * @return the payload data version.
120      */
121     short getPayloadVersion();
122
123     /**
124      * Sets the payload data version of the follower.
125      *
126      * @param payloadVersion the payload data version.
127      */
128     void setPayloadVersion(short payloadVersion);
129
130     /**
131      * Returns the the raft version of the follower.
132      *
133      * @return the raft version of the follower.
134      */
135     short getRaftVersion();
136
137     /**
138      * Sets the raft version of the follower.
139      *
140      * @param raftVersion the raft version.
141      */
142     void setRaftVersion(short raftVersion);
143
144     /**
145      * Returns the LeaderInstallSnapshotState for the in progress install snapshot.
146      *
147      * @return the LeaderInstallSnapshotState if a snapshot install is in progress, null otherwise.
148      */
149     @Nullable
150     LeaderInstallSnapshotState getInstallSnapshotState();
151
152     /**
153      * Sets the LeaderInstallSnapshotState when an install snapshot is initiated.
154      *
155      * @param state the LeaderInstallSnapshotState
156      */
157     void setLeaderInstallSnapshotState(@Nonnull LeaderInstallSnapshotState state);
158
159     /**
160      * Clears the LeaderInstallSnapshotState when an install snapshot is complete.
161      */
162     void clearLeaderInstallSnapshotState();
163 }