Interface LogStore
- All Known Implementing Classes:
FileLogStore, MemoryLogStore
public interface LogStore
The durable state of a Raft voter (srad/agentspaces-js.md JS-N-06, the
Java twin of
@agentspaces/ordered's LogStore): the term, the
vote, and the log entries, each written by RaftLog before
any reply that depends on it leaves, so a voter that restarts never votes
twice in a term and never loses an entry it acknowledged. One shape for
Java and JavaScript, so membership change and snapshots later land once in
both.
Every method is synchronous and returns only once the write is durable to
the store's own standard: MemoryLogStore is durable until the
process ends, FileLogStore until the disk does. A method that throws
leaves the log's in-memory state exactly as it was before the attempted
write, and the reply unsent; the log counts the failure and carries on.
Indexes are 1-based, as in RaftLog: the first entry is index 1.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordWhat a store holds; an empty store is term 0, no vote, no entries. -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(long fromIndex, List<RaftMessages.LogEntry> entries) Appends entries from 1-basedfromIndex, first removing any entry at or after it; returns once the entries are durable.load()Reads the store.voidsaveTermVote(long term, PeerId votedFor) Persists the term and the vote; returns once they are durable.voidtruncateFrom(long index) Removes the entries at and after 1-basedindex.
-
Method Details
-
load
Reads the store.- Returns:
- the durable state
- Throws:
IOException- when the store cannot be read
-
saveTermVote
Persists the term and the vote; returns once they are durable.- Parameters:
term- the termvotedFor- the vote cast in it, ornullfor none- Throws:
IOException- when the write did not become durable
-
append
Appends entries from 1-basedfromIndex, first removing any entry at or after it; returns once the entries are durable.- Parameters:
fromIndex- the index the first ofentriestakesentries- the entries to append- Throws:
IOException- when the write did not become durable
-
truncateFrom
Removes the entries at and after 1-basedindex.- Parameters:
index- the first index to drop- Throws:
IOException- when the write did not become durable
-