Interface RaftActorSnapshotCohort

All Known Implementing Classes:
NoopRaftActorSnapshotCohort

public interface RaftActorSnapshotCohort
Interface for a class that participates in raft actor snapshotting.
Author:
Thomas Pantelis
  • Method Details

    • createSnapshot

      void createSnapshot(@NonNull ActorRef actorRef, @NonNull Optional<OutputStream> installSnapshotStream)
      This method is called by the RaftActor when a snapshot needs to be created. The implementation should send a CaptureSnapshotReply to the given actor.
      Parameters:
      actorRef - the actor to which to respond
      installSnapshotStream - Optional OutputStream that is present if the snapshot is to also be installed on a follower. The implementation must serialize its state to the OutputStream and return the installSnapshotStream instance in the CaptureSnapshotReply along with the snapshot State instance. The snapshot State is serialized directly to the snapshot store while the OutputStream is used to send the state data to follower(s) in chunks. The deserializeSnapshot(com.google.common.io.ByteSource) method is used to convert the serialized data back to a State instance on the follower end. The serialization for snapshot install is passed off so the cost of serialization is not charged to the raft actor's thread.
    • applySnapshot

      void applySnapshot(@NonNull Snapshot.State snapshotState)
      This method is called to apply a snapshot installed by the leader.
      Parameters:
      snapshotState - a snapshot of the state of the actor
    • deserializeSnapshot

      @NonNull Snapshot.State deserializeSnapshot(@NonNull ByteSource snapshotBytes) throws IOException
      This method is called to de-serialize snapshot data that was previously serialized via createSnapshot(akka.actor.ActorRef, java.util.Optional<java.io.OutputStream>) to a State instance.
      Parameters:
      snapshotBytes - the ByteSource containing the serialized data
      Returns:
      the converted snapshot State
      Throws:
      IOException - if an error occurs accessing the ByteSource or de-serializing