Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix warnings and clean up javadocs in sal-akka-raft
[controller.git]
/
opendaylight
/
md-sal
/
sal-akka-raft
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
cluster
/
raft
/
ElectionTerm.java
diff --git
a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java
b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java
index 9c0a4fbffd5a03bf8e645e4d5aab9f72e66b507c..ff79004bcebdcaea3ff541951c3a5a170e5e74ce 100644
(file)
--- a/
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java
+++ b/
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ElectionTerm.java
@@
-8,41
+8,48
@@
package org.opendaylight.controller.cluster.raft;
package org.opendaylight.controller.cluster.raft;
+import javax.annotation.Nullable;
+
/**
* ElectionTerm contains information about a RaftActors election term.
* <p>
* This information includes the last known current term of the RaftActor
/**
* ElectionTerm contains information about a RaftActors election term.
* <p>
* This information includes the last known current term of the RaftActor
- * and which
peer was voted for by the RaftActor in that term
+ * and which
candidate was voted for by the RaftActor in that term.
* <p>
* <p>
- * This class ensures that election term information is persisted
+ * This class ensures that election term information is persisted
.
*/
public interface ElectionTerm {
/**
*/
public interface ElectionTerm {
/**
- * latest term server has seen (initialized to 0
- * on first boot, increases monotonically)
+ * Returns the current leader's Raft term.
+ *
+ * @return the current leader's Raft term.
*/
long getCurrentTerm();
/**
*/
long getCurrentTerm();
/**
- * candidateId that received vote in current
- * term (or null if none)
+ * Returns the id of the candidate that this server voted for in current term.
+ *
+ * @return candidate id that received the vote or null if no candidate was voted for.
*/
*/
+ @Nullable
String getVotedFor();
/**
String getVotedFor();
/**
- * Called when we need to update the current term either because we received
- * a message from someone with a more uptodate term or because we just voted
- * for someone
+ * This method updates the in-memory election term state. This method should be called when recovering election
+ * state from persistent storage.
*
*
- * @param
currentTerm
- * @param votedFor
+ * @param
term the election term.
+ * @param votedFor
the candidate id that was voted for.
*/
*/
- void update(long
currentTerm,
String votedFor);
+ void update(long
term, @Nullable
String votedFor);
/**
/**
+ * This method updates the in-memory election term state and persists it so it can be recovered on next restart.
+ * This method should be called when starting a new election or when a Raft RPC message is received with a higher
+ * term.
*
*
- * @param
currentTerm
- * @param votedFor
+ * @param
term the election term.
+ * @param votedFor
the candidate id that was voted for.
*/
*/
- void updateAndPersist(long
currentTerm,
String votedFor);
+ void updateAndPersist(long
term, @Nullable
String votedFor);
}
}