Interface SnapshotState

  • All Known Implementing Classes:
    SnapshotManager

    public interface SnapshotState
    Interface for a snapshot phase state.
    Author:
    Moiz Raja, Thomas Pantelis
    • Method Detail

      • isCapturing

        boolean isCapturing()
        Returns whether or not a capture is in progress.
        Returns:
        true when a snapshot is being captured, false otherwise
      • capture

        boolean capture​(ReplicatedLogEntry lastLogEntry,
                        long replicatedToAllIndex)
        Initiates a capture snapshot.
        Parameters:
        lastLogEntry - the last entry in the replicated log
        replicatedToAllIndex - the current replicatedToAllIndex
        Returns:
        true if capture was started
      • captureToInstall

        boolean captureToInstall​(ReplicatedLogEntry lastLogEntry,
                                 long replicatedToAllIndex,
                                 String targetFollower)
        Initiates a capture snapshot for the purposing of installing the snapshot on a follower.
        Parameters:
        lastLogEntry - the last entry in the replicated log
        replicatedToAllIndex - the current replicatedToAllIndex
        targetFollower - the id of the follower on which to install
        Returns:
        true if capture was started
      • captureWithForcedTrim

        boolean captureWithForcedTrim​(ReplicatedLogEntry lastLogEntry,
                                      long replicatedToAllIndex)
        Initiates a capture snapshot, while enforcing trimming of the log up to lastAppliedIndex.
        Parameters:
        lastLogEntry - the last entry in the replicated log
        replicatedToAllIndex - the current replicatedToAllIndex
        Returns:
        true if capture was started
      • apply

        void apply​(ApplySnapshot snapshot)
        Applies a snapshot on a follower that was installed by the leader.
        Parameters:
        snapshot - the Snapshot to apply.
      • persist

        void persist​(Snapshot.State snapshotState,
                     Optional<OutputStream> installSnapshotStream,
                     long totalMemory)
        Persists a snapshot.
        Parameters:
        snapshotState - the snapshot State
        installSnapshotStream - Optional OutputStream that is present if the snapshot is to also be installed on a follower.
        totalMemory - the total memory threshold
      • commit

        void commit​(long sequenceNumber,
                    long timeStamp)
        Commit the snapshot by trimming the log.
        Parameters:
        sequenceNumber - the sequence number of the persisted snapshot
        timeStamp - the time stamp of the persisted snapshot
      • rollback

        void rollback()
        Rolls back the snapshot on failure.
      • trimLog

        long trimLog​(long desiredTrimIndex)
        Trims the in-memory log.
        Parameters:
        desiredTrimIndex - the desired index to trim from
        Returns:
        the actual trim index