Martin Fowler
An index in the write ahead log showing the last successful replication.
Solution
The high-water mark is an index into the log file that records the last log entry that is known to have successfully replicated to a Quorum of followers. The leader also passes on the high-water mark to its followers during its replication. All servers in the cluster should only transmit data to clients that reflects updates that are below the high-water mark.
Here’s the sequence of operations.
Figure 1: High-Water Mark
For each log entry, the leader appends it to its local write ahead log, and then sends it to all the followers.
leader (class ReplicationModule…)
private Long appendAndReplicate(byte[] data) { Long lastLogEntryIndex = appendToLocalLog(data); logger.info(“Replicating log entries from index ” + lastLogEntryIndex); replicateOnFollowers(lastLogEntryIndex); return lastLogEntryIndex; } private void replicateOnFollowers(Long entryAtIndex) { for (final FollowerHandler follower : followers) { replicateOn(follower, entryAtIndex); //send replication requests to followers
To read the full article click on the 'post' link at the top.