Interface RaftStateMachine


public interface RaftStateMachine
A state machine interface.
Since:
14.0
  • Method Summary

    Modifier and Type
    Method
    Description
    org.infinispan.commons.io.ByteBuffer
    apply(org.infinispan.commons.io.ByteBuffer buffer)
    Applies the data from the RAFT protocol.
    void
    init(RaftChannel raftChannel)
    Initializes this instance with the RaftChannel to be used to send the data.
    void
    Discards current state and reads the state from DataInput.
    void
    Writes the current state into the DataOutput.
  • Method Details

    • init

      void init(RaftChannel raftChannel)
      Initializes this instance with the RaftChannel to be used to send the data.
      Parameters:
      raftChannel - The RaftChannel instance.
    • apply

      org.infinispan.commons.io.ByteBuffer apply(org.infinispan.commons.io.ByteBuffer buffer) throws Exception
      Applies the data from the RAFT protocol.

      The RAFT protocol ensures that this method is invoked in the same order in all the members.

      Parameters:
      buffer - The data.
      Returns:
      A ByteBuffer with the response.
      Throws:
      Exception - If it fails to apply the data in ByteBuffer.
    • readStateFrom

      void readStateFrom(DataInput dataInput) throws IOException
      Discards current state and reads the state from DataInput.

      There are 2 scenarios where this method may be invoked:

      1. when this node starts, it may receive the state from the RAFT leader. 2. when this node starts, it reads the persisted snapshot if available.

      Parameters:
      dataInput - The DataInput with the snapshot.
      Throws:
      IOException - If an I/O error happens.
    • writeStateTo

      void writeStateTo(DataOutput dataOutput) throws IOException
      Writes the current state into the DataOutput.

      This method is invoked to truncate the RAFT logs.

      Parameters:
      dataOutput - The DataOutput to store the snapshot.
      Throws:
      IOException - If an I/O error happens.