+ * This method checks if the next replicate message can be sent to the follower. This is an optimization to avoid
+ * sending duplicate message too frequently if the last replicate message was sent and no reply has been received
+ * yet within the current heart beat interval
+ *
+ * @return true if it is OK to replicate, false otherwise
+ */
+ public boolean okToReplicate() {
+ if (peerInfo.getVotingState() == VotingState.VOTING_NOT_INITIALIZED) {
+ return false;
+ }
+
+ // Return false if we are trying to send duplicate data before the heartbeat interval
+ if (getNextIndex() == lastReplicatedIndex && lastReplicatedStopwatch.elapsed(TimeUnit.MILLISECONDS)
+ < context.getConfigParams().getHeartBeatInterval().toMillis()) {
+ return false;
+ }
+
+ resetLastReplicated();
+ return true;
+ }
+
+ private void resetLastReplicated() {
+ lastReplicatedIndex = getNextIndex();
+ if (lastReplicatedStopwatch.isRunning()) {
+ lastReplicatedStopwatch.reset();
+ }
+ lastReplicatedStopwatch.start();
+ }
+
+ /**
+ * Returns the log entry payload data version of the follower.
+ *
+ * @return the payload data version.
+ */
+ public short getPayloadVersion() {
+ return payloadVersion;
+ }
+
+ /**
+ * Sets the payload data version of the follower.
+ *
+ * @param payloadVersion the payload data version.
+ */
+ public void setPayloadVersion(final short payloadVersion) {
+ this.payloadVersion = payloadVersion;
+ }
+
+ /**
+ * Returns the the raft version of the follower.
+ *
+ * @return the raft version of the follower.
+ */
+ public short getRaftVersion() {
+ return raftVersion;
+ }
+
+ /**
+ * Sets the raft version of the follower.
+ *
+ * @param raftVersion the raft version.
+ */
+ public void setRaftVersion(final short raftVersion) {
+ this.raftVersion = raftVersion;
+ }
+
+ /**
+ * Returns the LeaderInstallSnapshotState for the in progress install snapshot.
+ *
+ * @return the LeaderInstallSnapshotState if a snapshot install is in progress, null otherwise.
+ */
+ @Nullable
+ public LeaderInstallSnapshotState getInstallSnapshotState() {
+ return installSnapshotState;
+ }
+
+ /**
+ * Sets the LeaderInstallSnapshotState when an install snapshot is initiated.
+ *
+ * @param state the LeaderInstallSnapshotState