Bug 2890: Chunk AppendEntries when single payload size exceeds threshold
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / FollowerLogInformationImpl.java
index 883bfbb4e4184f0cbf0843002dfa3498ca13f622..8bd0cf3d34f4639a1e053cc6c17158e469a4422f 100644 (file)
@@ -46,6 +46,8 @@ public class FollowerLogInformationImpl implements FollowerLogInformation {
 
     private LeaderInstallSnapshotState installSnapshotState;
 
+    private long slicedLogEntryIndex = NO_INDEX;
+
     /**
      * Constructs an instance.
      *
@@ -92,6 +94,12 @@ public class FollowerLogInformationImpl implements FollowerLogInformation {
 
     @Override
     public boolean setMatchIndex(long matchIndex) {
+        // If the new match index is the index of the entry currently being sliced, then we know slicing is complete
+        // and the follower received the entry and responded so clear the slicedLogEntryIndex
+        if (isLogEntrySlicingInProgress() && slicedLogEntryIndex == matchIndex) {
+            slicedLogEntryIndex = NO_INDEX;
+        }
+
         if (this.matchIndex != matchIndex) {
             this.matchIndex = matchIndex;
             return true;
@@ -210,6 +218,16 @@ public class FollowerLogInformationImpl implements FollowerLogInformation {
         installSnapshotState = null;
     }
 
+    @Override
+    public void setSlicedLogEntryIndex(long index) {
+        slicedLogEntryIndex  = index;
+    }
+
+    @Override
+    public boolean isLogEntrySlicingInProgress() {
+        return slicedLogEntryIndex != NO_INDEX;
+    }
+
     @Override
     public String toString() {
         return "FollowerLogInformationImpl [id=" + getId() + ", nextIndex=" + nextIndex + ", matchIndex=" + matchIndex