Interface RaftStateMachine
public interface RaftStateMachine
A state machine interface.
- Since:
- 14.0
-
Method Summary
Modifier and TypeMethodDescriptionorg.infinispan.commons.io.ByteBufferapply(org.infinispan.commons.io.ByteBuffer buffer) Applies the data from the RAFT protocol.voidinit(RaftChannel raftChannel) Initializes this instance with theRaftChannelto be used to send the data.voidreadStateFrom(DataInput dataInput) Discards current state and reads the state fromDataInput.voidwriteStateTo(DataOutput dataOutput) Writes the current state into theDataOutput.
-
Method Details
-
init
Initializes this instance with theRaftChannelto be used to send the data.- Parameters:
raftChannel- TheRaftChannelinstance.
-
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
ByteBufferwith the response. - Throws:
Exception- If it fails to apply the data inByteBuffer.
-
readStateFrom
Discards current state and reads the state fromDataInput.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- TheDataInputwith the snapshot.- Throws:
IOException- If an I/O error happens.
-
writeStateTo
Writes the current state into theDataOutput.This method is invoked to truncate the RAFT logs.
- Parameters:
dataOutput- TheDataOutputto store the snapshot.- Throws:
IOException- If an I/O error happens.
-