Make RequestVoteReply final
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / messages / RequestVote.java
index 5828e439eba2bbc78387a06a46af806439394891..fc6d48906a73b63f34eaf053792b2c3a0cb1c3c0 100644 (file)
@@ -11,10 +11,8 @@ 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;
@@ -25,18 +23,13 @@ public class RequestVote {
     // term of candidate’s last log entry (§5.4)
     private final long lastLogTerm;
 
-    public RequestVote(long term, String candidateId, long lastLogIndex,
-        long lastLogTerm) {
-        this.term = term;
+    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;
     }
@@ -48,4 +41,13 @@ public class RequestVote {
     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();
+    }
 }