Merge "Fix for Bug 2727 - Upgrade Akka from 2.3.4 to 2.3.9"
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / RequestVote.java
index 5828e439eba2bbc78387a06a46af806439394891..8f162ae254ac1d9faaefbc89e8d6bed33dbd1b85 100644 (file)
@@ -11,28 +11,31 @@ package org.opendaylight.controller.cluster.raft.messages;
 /**
  * Invoked by candidates to gather votes (§5.2).
  */
-public class RequestVote {
-
-    // candidate’s term
-    private final long term;
+public class RequestVote extends AbstractRaftRPC {
+    private static final long serialVersionUID = -6967509186297108657L;
 
     // 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.term = term;
+        super(term);
         this.candidateId = candidateId;
         this.lastLogIndex = lastLogIndex;
         this.lastLogTerm = lastLogTerm;
     }
 
+    // added for testing while serialize-messages=on
+    public RequestVote() {
+    }
+
+    @Override
     public long getTerm() {
         return term;
     }
@@ -48,4 +51,25 @@ public class RequestVote {
     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() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("RequestVote [term=").append(term).append(", candidateId=").append(candidateId)
+                .append(", lastLogIndex=").append(lastLogIndex).append(", lastLogTerm=").append(lastLogTerm)
+                .append("]");
+        return builder.toString();
+    }
 }