c5524bc1673801680cb002757b6b8edc004bb629
[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      * @return
18      */
19     long incrNextIndex();
20
21     /**
22      * Decrement the value of the nextIndex
23      * @return
24      */
25     long decrNextIndex();
26
27     /**
28      * Sets the index of the next log entry for this follower.
29      *
30      * @param nextIndex
31      * @return true if the new index differed from the current index and the current index was updated, false
32      *              otherwise.
33      */
34     boolean setNextIndex(long nextIndex);
35
36     /**
37      * Increment the value of the matchIndex
38      * @return
39      */
40     long incrMatchIndex();
41
42     /**
43      * Sets the index of the highest log entry for this follower.
44      *
45      * @param matchIndex
46      * @return true if the new index differed from the current index and the current index was updated, false
47      *              otherwise.
48      */
49     boolean setMatchIndex(long matchIndex);
50
51     /**
52      * The identifier of the follower
53      * This could simply be the url of the remote actor
54      */
55     String getId();
56
57     /**
58      * for each server, index of the next log entry
59      * to send to that server (initialized to leader
60      *    last log index + 1)
61      */
62     long getNextIndex();
63
64     /**
65      * for each server, index of highest log entry
66      * known to be replicated on server
67      *    (initialized to 0, increases monotonically)
68      */
69     long getMatchIndex();
70
71     /**
72      * Checks if the follower is active by comparing the last updated with the duration
73      * @return boolean
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      * @return time in milliseconds
91      */
92     long timeSinceLastActivity();
93
94     /**
95      * This method checks if it is ok to replicate
96      *
97      * @return true if it is ok to replicate
98      */
99     boolean okToReplicate();
100
101     /**
102      * Returns the payload data version of the follower.
103      */
104     short getPayloadVersion();
105
106     /**
107      * Sets the payload data version of the follower.
108      */
109     void setPayloadVersion(short payloadVersion);
110 }