Bug 6540: Refactor FollowerToSnapshot to its own class
[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 /**
11  * The state of the followers log as known by the Leader
12  */
13 public interface FollowerLogInformation {
14
15     /**
16      * Increment the value of the nextIndex
17      *
18      * @return the new value of nextIndex
19      */
20     long incrNextIndex();
21
22     /**
23      * Decrement the value of the nextIndex
24      *
25      * @return the new value of nextIndex
26      */
27     long decrNextIndex();
28
29     /**
30      * Sets the index of the next log entry for this follower.
31      *
32      * @param nextIndex
33      * @return true if the new index differed from the current index and the current index was updated, false
34      *              otherwise.
35      */
36     boolean setNextIndex(long nextIndex);
37
38     /**
39      * Increment the value of the matchIndex
40      *
41      * @return the new value of matchIndex
42      */
43     long incrMatchIndex();
44
45     /**
46      * Sets the index of the highest log entry for this follower.
47      *
48      * @param matchIndex
49      * @return true if the new index differed from the current index and the current index was updated, false
50      *              otherwise.
51      */
52     boolean setMatchIndex(long matchIndex);
53
54     /**
55      *
56      * @return the identifier of the follower. This could simply be the url of the remote actor.
57      */
58     String getId();
59
60     /**
61      * @return index of the next log entry to send to that server (initialized to leader last log index + 1)
62      */
63     long getNextIndex();
64
65     /**
66      * @return index of highest log entry known to be replicated on server (initialized to 0, increases monotonically)
67      */
68     long getMatchIndex();
69
70     /**
71      * Checks if the follower is active by comparing the last updated with the duration
72      *
73      * @return true if follower is active, false otherwise
74      */
75     boolean isFollowerActive();
76
77     /**
78      * restarts the timeout clock of the follower
79      */
80     void markFollowerActive();
81
82     /**
83      * This will stop the timeout clock
84      */
85     void markFollowerInActive();
86
87
88     /**
89      * This will return the active time of follower, since it was last reset
90      *
91      * @return time in milliseconds since the last activity from the follower
92      */
93     long timeSinceLastActivity();
94
95     /**
96      * This method checks if it is ok to replicate
97      *
98      * @return true if it is ok to replicate, false otherwise
99      */
100     boolean okToReplicate();
101
102     /**
103      * @return the payload data version of the follower.
104      */
105     short getPayloadVersion();
106
107     /**
108      * Sets the payload data version of the follower.
109      */
110     void setPayloadVersion(short payloadVersion);
111
112     /**
113      * @return the raft version of the follower.
114      */
115     short getRaftVersion();
116
117     /**
118      * Sets the raft version of the follower.
119      */
120     void setRaftVersion(short payloadVersion);
121 }