Send leader's full address via AppendEntries
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / behaviors / AbstractRaftActorBehavior.java
index 400f110865f53a37e64d223f7cbe894c912262f6..087c656b1836daaf9c05ac7b91e32eba1057c02c 100644 (file)
@@ -137,7 +137,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior {
                     appendEntries.getTerm(), currentTerm());
 
             sender.tell(new AppendEntriesReply(context.getId(), currentTerm(), false, lastIndex(), lastTerm(),
-                    context.getPayloadVersion()), actor());
+                    context.getPayloadVersion(), false, false, appendEntries.getLeaderRaftVersion()), actor());
             return this;
         }
 
@@ -347,7 +347,7 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior {
     }
 
     /**
-     * Returns the actual term of the entry in replicated log for the given index or -1 if not found.
+     * Returns the actual term of the entry in the replicated log for the given index or -1 if not found.
      *
      * @return the log entry term or -1 if not found
      */
@@ -364,6 +364,20 @@ public abstract class AbstractRaftActorBehavior implements RaftActorBehavior {
         return -1;
     }
 
+    /**
+     * Returns the actual term of the entry in the replicated log for the given index or, if not present, returns the
+     * snapshot term if the given index is in the snapshot or -1 otherwise.
+     *
+     * @return the term or -1 otherwise
+     */
+    protected long getLogEntryOrSnapshotTerm(final long index) {
+        if (context.getReplicatedLog().isInSnapshot(index)) {
+            return context.getReplicatedLog().getSnapshotTerm();
+        }
+
+        return getLogEntryTerm(index);
+    }
+
     /**
      * Applies the log entries up to the specified index that is known to be committed to the state machine.
      *