Class MetaStore

java.lang.Object
io.atomix.raft.storage.system.MetaStore
All Implemented Interfaces:
JournalMetaStore, AutoCloseable

public class MetaStore extends Object implements JournalMetaStore, AutoCloseable
Manages persistence of server configurations.

The server metastore is responsible for persisting server configurations. Each server persists their current term and last vote as is dictated by the Raft consensus algorithm. Additionally, the metastore is responsible for storing the last know server Configuration, including cluster membership.

  • Constructor Details

  • Method Details

    • storeTerm

      public void storeTerm(long term)
      Stores the current server term.
      Parameters:
      term - The current server term.
    • loadTerm

      public long loadTerm()
      Loads the stored server term.
      Returns:
      The stored server term.
    • storeVote

      public void storeVote(MemberId vote)
      Stores the last voted server.
      Parameters:
      vote - The server vote.
    • loadVote

      public MemberId loadVote()
      Loads the last vote for the server.
      Returns:
      The last vote for the server.
    • storeLastFlushedIndex

      public void storeLastFlushedIndex(long index)
      Specified by:
      storeLastFlushedIndex in interface JournalMetaStore
    • loadLastFlushedIndex

      public long loadLastFlushedIndex()
      Specified by:
      loadLastFlushedIndex in interface JournalMetaStore
    • resetLastFlushedIndex

      public void resetLastFlushedIndex()
      Specified by:
      resetLastFlushedIndex in interface JournalMetaStore
    • hasLastFlushedIndex

      public boolean hasLastFlushedIndex()
      Specified by:
      hasLastFlushedIndex in interface JournalMetaStore
    • storeCommitIndex

      public void storeCommitIndex(long index)
    • hasCommitIndex

      public boolean hasCommitIndex()
    • commitIndex

      public long commitIndex()
      Returns:
      the currentCommitIndex or -1 if not present. Check with hasCommitIndex() if it is initialized.
    • storeConfiguration

      public void storeConfiguration(Configuration configuration)
      Stores the current cluster configuration.
      Parameters:
      configuration - The current cluster configuration.
    • loadConfiguration

      public Configuration loadConfiguration()
      Loads the current cluster configuration.
      Returns:
      The current cluster configuration.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • toString

      public String toString()
      Overrides:
      toString in class Object