Make Raft messages serializable
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / RequestVote.java
index 981da17ce143389b75e8303b4bde9fd9fd582ad1..310968de950bf2f5e4ff31bcbcc3d7718ad618a8 100644 (file)
@@ -8,19 +8,21 @@
 
 package org.opendaylight.controller.cluster.raft.messages;
 
+import java.io.Serializable;
+
 /**
  * Invoked by candidates to gather votes (§5.2).
  */
-public class RequestVote extends AbstractRaftRPC{
+public class RequestVote extends AbstractRaftRPC implements Serializable{
 
     // 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) {
@@ -30,6 +32,10 @@ public class RequestVote extends AbstractRaftRPC{
         this.lastLogTerm = lastLogTerm;
     }
 
+    // added for testing while serialize-messages=on
+    public RequestVote() {
+    }
+
     public long getTerm() {
         return term;
     }
@@ -45,4 +51,16 @@ public class RequestVote extends AbstractRaftRPC{
     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;
+    }
 }