Bug 7391: Fix out-of-order LeaderStateChange events
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / RequestVote.java
index 981da17ce143389b75e8303b4bde9fd9fd582ad1..fc6d48906a73b63f34eaf053792b2c3a0cb1c3c0 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.controller.cluster.raft.messages;
 /**
  * Invoked by candidates to gather votes (§5.2).
  */
-public class RequestVote extends AbstractRaftRPC{
+public class RequestVote extends AbstractRaftRPC {
+    private static final long serialVersionUID = -6967509186297108657L;
 
     // candidate requesting vote
     private final String candidateId;
@@ -22,18 +23,13 @@ public class RequestVote extends AbstractRaftRPC{
     // term of candidate’s last log entry (§5.4)
     private final long lastLogTerm;
 
-    public RequestVote(long term, String candidateId, long lastLogIndex,
-        long lastLogTerm) {
+    public RequestVote(long term, String candidateId, long lastLogIndex, long lastLogTerm) {
         super(term);
         this.candidateId = candidateId;
         this.lastLogIndex = lastLogIndex;
         this.lastLogTerm = lastLogTerm;
     }
 
-    public long getTerm() {
-        return term;
-    }
-
     public String getCandidateId() {
         return candidateId;
     }
@@ -45,4 +41,13 @@ public class RequestVote extends AbstractRaftRPC{
     public long getLastLogTerm() {
         return lastLogTerm;
     }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("RequestVote [term=").append(getTerm()).append(", candidateId=").append(candidateId)
+                .append(", lastLogIndex=").append(lastLogIndex).append(", lastLogTerm=").append(lastLogTerm)
+                .append("]");
+        return builder.toString();
+    }
 }