public Follower(RaftActorContext context) {
super(context, RaftState.Follower);
- scheduleElection(electionDuration());
-
initialSyncStatusTracker = new InitialSyncStatusTracker(context.getActor());
+
+ if(context.getPeerAddresses().isEmpty()){
+ actor().tell(ELECTION_TIMEOUT, actor());
+ } else {
+ scheduleElection(electionDuration());
+ }
+
}
private boolean isLogEntryPresent(long index){
if (snapshotTracker != null) {
// if snapshot install is in progress, follower should just acknowledge append entries with a reply.
AppendEntriesReply reply = new AppendEntriesReply(context.getId(), currentTerm(), true,
- lastIndex(), lastTerm());
+ lastIndex(), lastTerm(), context.getPayloadVersion());
if(LOG.isDebugEnabled()) {
LOG.debug("{}: snapshot install is in progress, replying immediately with {}", logName(), reply);
// If we got here then we do appear to be talking to the leader
leaderId = appendEntries.getLeaderId();
+ setLeaderPayloadVersion(appendEntries.getPayloadVersion());
+
// 2. Reply false if log doesn’t contain an entry at prevLogIndex
// whose term matches prevLogTerm (§5.3)
logName(), lastIndex, lastTerm());
sender.tell(new AppendEntriesReply(context.getId(), currentTerm(), false, lastIndex,
- lastTerm()), actor());
+ lastTerm(), context.getPayloadVersion()), actor());
return this;
}
}
AppendEntriesReply reply = new AppendEntriesReply(context.getId(), currentTerm(), true,
- lastIndex, lastTerm());
+ lastIndex, lastTerm(), context.getPayloadVersion());
if(LOG.isTraceEnabled()) {
LOG.trace("{}: handleAppendEntries returning : {}", logName(), reply);
sender.tell(reply, actor());
- if (!context.isSnapshotCaptureInitiated()) {
+ if (!context.getSnapshotManager().isCapturing()) {
super.performSnapshotWithoutCapture(appendEntries.getReplicatedToAllIndex());
}