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 / AppendEntriesReply.java
index d811464cba9ba3f6427f3bda972c3fc888190cbb..01fef006a922a5b69290df2eaf19a4017ead65d9 100644 (file)
@@ -11,19 +11,34 @@ package org.opendaylight.controller.cluster.raft.messages;
 /**
  * Reply for the AppendEntriesRpc message
  */
-public class AppendEntriesReply {
-    // currentTerm, for leader to update itself
-    private final long term;
+public class AppendEntriesReply extends AbstractRaftRPC {
+    private static final long serialVersionUID = -7487547356392536683L;
 
     // true if follower contained entry matching
     // prevLogIndex and prevLogTerm
     private final boolean success;
 
-    public AppendEntriesReply(long term, boolean success) {
-        this.term = term;
+    // The index of the last entry in the followers log
+    // This will be used to set the matchIndex for the follower on the
+    // Leader
+    private final long logLastIndex;
+
+    private final long logLastTerm;
+
+    // The followerId - this will be used to figure out which follower is
+    // responding
+    private final String followerId;
+
+    public AppendEntriesReply(String followerId, long term, boolean success, long logLastIndex, long logLastTerm) {
+        super(term);
+
+        this.followerId = followerId;
         this.success = success;
+        this.logLastIndex = logLastIndex;
+        this.logLastTerm = logLastTerm;
     }
 
+    @Override
     public long getTerm() {
         return term;
     }
@@ -31,4 +46,25 @@ public class AppendEntriesReply {
     public boolean isSuccess() {
         return success;
     }
+
+    public long getLogLastIndex() {
+        return logLastIndex;
+    }
+
+    public long getLogLastTerm() {
+        return logLastTerm;
+    }
+
+    public String getFollowerId() {
+        return followerId;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("AppendEntriesReply [term=").append(term).append(", success=").append(success)
+                .append(", logLastIndex=").append(logLastIndex).append(", logLastTerm=").append(logLastTerm)
+                .append(", followerId=").append(followerId).append("]");
+        return builder.toString();
+    }
 }