/**
* Invoked by candidates to gather votes (§5.2).
*/
-public class RequestVote extends AbstractRaftRPC{
+public class RequestVote extends AbstractRaftRPC {
+ private static final long serialVersionUID = 1L;
// candidate requesting vote
- private final String candidateId;
+ private String candidateId;
// index of candidate’s last log entry (§5.4)
- private final long lastLogIndex;
+ private long lastLogIndex;
// term of candidate’s last log entry (§5.4)
- private final long lastLogTerm;
+ private long lastLogTerm;
public RequestVote(long term, String candidateId, long lastLogIndex,
long lastLogTerm) {
this.lastLogTerm = lastLogTerm;
}
+ // added for testing while serialize-messages=on
+ public RequestVote() {
+ }
+
public long getTerm() {
return term;
}
public long getLastLogTerm() {
return lastLogTerm;
}
+
+ public void setCandidateId(String candidateId) {
+ this.candidateId = candidateId;
+ }
+
+ public void setLastLogIndex(long lastLogIndex) {
+ this.lastLogIndex = lastLogIndex;
+ }
+
+ public void setLastLogTerm(long lastLogTerm) {
+ this.lastLogTerm = lastLogTerm;
+ }
+
+ @Override public String toString() {
+ final StringBuilder sb =
+ new StringBuilder("RequestVote{");
+ sb.append("term='").append(getTerm()).append('\'');
+ sb.append("candidateId='").append(candidateId).append('\'');
+ sb.append(", lastLogIndex=").append(lastLogIndex);
+ sb.append(", lastLogTerm=").append(lastLogTerm);
+ sb.append('}');
+ return sb.toString();
+ }
}