Skip to content

Commit

Permalink
Log indexed entries after writing to the log on Raft followers.
Browse files Browse the repository at this point in the history
  • Loading branch information
kuujo committed Jul 16, 2017
1 parent c90c75d commit 8fb6917
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Expand Up @@ -121,8 +121,8 @@ private void appendInitialEntries() {
final long term = context.getTerm(); final long term = context.getTerm();


final RaftLogWriter writer = context.getLogWriter(); final RaftLogWriter writer = context.getLogWriter();
final Indexed<RaftLogEntry> indexed = writer.append(new InitializeEntry(term, appender.getTime())); final Indexed<RaftLogEntry> entry = writer.append(new InitializeEntry(term, appender.getTime()));
log.trace("Appended {}", indexed.index()); log.trace("Appended {}", entry);


// Append a configuration entry to propagate the leader's cluster configuration. // Append a configuration entry to propagate the leader's cluster configuration.
configure(context.getCluster().getMembers()); configure(context.getCluster().getMembers());
Expand Down
Expand Up @@ -227,8 +227,8 @@ protected void appendEntries(AppendRequest request, CompletableFuture<AppendResp
// the log and append the leader's entry. // the log and append the leader's entry.
if (existingEntry.entry().term() != entry.term()) { if (existingEntry.entry().term() != entry.term()) {
writer.truncate(index - 1); writer.truncate(index - 1);
writer.append(entry); Indexed<RaftLogEntry> indexed = writer.append(entry);
log.trace("Appended {} at index {}", entry, index); log.trace("Appended {}", indexed);
} }
} }
// If the last written entry is equal to the append entry index, we don't need // If the last written entry is equal to the append entry index, we don't need
Expand All @@ -238,8 +238,8 @@ else if (lastEntry.index() == index) {
// the log and append the leader's entry. // the log and append the leader's entry.
if (lastEntry.entry().term() != entry.term()) { if (lastEntry.entry().term() != entry.term()) {
writer.truncate(index - 1); writer.truncate(index - 1);
writer.append(entry); Indexed<RaftLogEntry> indexed = writer.append(entry);
log.trace("Appended {} at index {}", entry, index); log.trace("Appended {}", indexed);
} }
} }
// Otherwise, this entry is being appended at the end of the log. // Otherwise, this entry is being appended at the end of the log.
Expand All @@ -250,14 +250,14 @@ else if (lastEntry.index() == index) {
} }


// Append the entry and log a message. // Append the entry and log a message.
writer.append(entry); Indexed<RaftLogEntry> indexed = writer.append(entry);
log.trace("Appended {} at index {}", entry, index); log.trace("Appended {}", indexed);
} }
} }
// Otherwise, if the last entry is null just append the entry and log a message. // Otherwise, if the last entry is null just append the entry and log a message.
else { else {
writer.append(entry); Indexed<RaftLogEntry> indexed = writer.append(entry);
log.trace("Appended {} at index {}", entry, index); log.trace("Appended {}", indexed);
} }


// If the last log index meets the commitIndex, break the append loop to avoid appending uncommitted entries. // If the last log index meets the commitIndex, break the append loop to avoid appending uncommitted entries.
Expand Down

0 comments on commit 8fb6917

Please sign in to comment.