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 Classes
    Modifier and Type
    Interface
    Description
    static final record 
    What a store holds; an empty store is term 0, no vote, no entries.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(long fromIndex, List<RaftMessages.LogEntry> entries)
    Appends entries from 1-based fromIndex, first removing any entry at or after it; returns once the entries are durable.
    Reads the store.
    void
    saveTermVote(long term, PeerId votedFor)
    Persists the term and the vote; returns once they are durable.
    void
    truncateFrom(long index)
    Removes the entries at and after 1-based index.
  • Method Details

    • load

      Reads the store.
      Returns:
      the durable state
      Throws:
      IOException - when the store cannot be read
    • saveTermVote

      void saveTermVote(long term, PeerId votedFor) throws IOException
      Persists the term and the vote; returns once they are durable.
      Parameters:
      term - the term
      votedFor - the vote cast in it, or null for none
      Throws:
      IOException - when the write did not become durable
    • append

      void append(long fromIndex, List<RaftMessages.LogEntry> entries) throws IOException
      Appends entries from 1-based fromIndex, first removing any entry at or after it; returns once the entries are durable.
      Parameters:
      fromIndex - the index the first of entries takes
      entries - the entries to append
      Throws:
      IOException - when the write did not become durable
    • truncateFrom

      void truncateFrom(long index) throws IOException
      Removes the entries at and after 1-based index.
      Parameters:
      index - the first index to drop
      Throws:
      IOException - when the write did not become durable