+public final class FollowerLogInformation {
+ public static final long NO_INDEX = -1;
+
+ private final Stopwatch stopwatch = Stopwatch.createUnstarted();
+
+ private final RaftActorContext context;
+
+ private long nextIndex;
+
+ private long matchIndex;
+
+ private long lastReplicatedIndex = -1L;
+
+ private final Stopwatch lastReplicatedStopwatch = Stopwatch.createUnstarted();
+
+ private short payloadVersion = -1;
+
+ // Assume the HELIUM_VERSION version initially for backwards compatibility until we obtain the follower's
+ // actual version via AppendEntriesReply. Although we no longer support the Helium version, a pre-Boron
+ // follower will not have the version field in AppendEntriesReply so it will be set to 0 which is
+ // HELIUM_VERSION.
+ private short raftVersion = RaftVersions.HELIUM_VERSION;
+
+ private final PeerInfo peerInfo;
+
+ private LeaderInstallSnapshotState installSnapshotState;
+
+ private long slicedLogEntryIndex = NO_INDEX;
+
+ private boolean needsLeaderAddress;
+
+ /**
+ * Constructs an instance.
+ *
+ * @param peerInfo the associated PeerInfo of the follower.
+ * @param matchIndex the initial match index.
+ * @param context the RaftActorContext.
+ */
+ @VisibleForTesting
+ FollowerLogInformation(final PeerInfo peerInfo, final long matchIndex, final RaftActorContext context) {
+ this.nextIndex = context.getCommitIndex();
+ this.matchIndex = matchIndex;
+ this.context = context;
+ this.peerInfo = Preconditions.checkNotNull(peerInfo);
+ }
+
+ /**
+ * Constructs an instance with no matching index.
+ *
+ * @param peerInfo the associated PeerInfo of the follower.
+ * @param context the RaftActorContext.
+ */
+ public FollowerLogInformation(final PeerInfo peerInfo, final RaftActorContext context) {
+ this(peerInfo, NO_INDEX, context);
+ }