Class CSTState

  • All Implemented Interfaces:
    ApplicationState, java.io.Serializable

    public class CSTState
    extends java.lang.Object
    implements ApplicationState
    Stores the data used to transfer the state to a recovering replica. This class serves the three different seeders defined in the CST optimized version for f=1. In that version, the newest replica to take the checkpoint is expected to send the hash of the checkpoint plus the upper portion of the log. The replica which took the checkpoint before that, i.e., the middle replica is expected to send the checkpoint it has plus hashes of the lower and upper portions of the log. The oldest replica to take the checkpoint must send the lower portion of the log. This object must be passed to the state manager class which will combine the replies from the seeders, validating the values and updating the state in the leecher.
    See Also:
    Serialized Form
    • Constructor Detail

      • CSTState

        public CSTState​(byte[] state,
                        byte[] hashCheckpoint,
                        CommandsInfo[] logLower,
                        byte[] hashLogLower,
                        CommandsInfo[] logUpper,
                        byte[] hashLogUpper,
                        int checkpointCID,
                        int lastCID,
                        int pid)
    • Method Detail

      • hasState

        public boolean hasState()
        Description copied from interface: ApplicationState
        Indicates if the sender replica had the state requested by the recovering replica
        Specified by:
        hasState in interface ApplicationState
        Returns:
        true if the sender replica had the state requested by the recovering replica, false otherwise
      • getSerializedState

        public byte[] getSerializedState()
        Description copied from interface: ApplicationState
        Byte array that must be a representation of the application state
        Specified by:
        getSerializedState in interface ApplicationState
        Returns:
        A byte array that must be a representation of the application state
      • getStateHash

        public byte[] getStateHash()
        Description copied from interface: ApplicationState
        Gets an secure hash of the application state
        Specified by:
        getStateHash in interface ApplicationState
        Returns:
        Secure hash of the application state
      • setSerializedState

        public void setSerializedState​(byte[] state)
        Description copied from interface: ApplicationState
        Sets a byte array that must be a representation of the application state
        Specified by:
        setSerializedState in interface ApplicationState
        Parameters:
        state - a byte array that must be a representation of the application state
      • getLastCID

        public int getLastCID()
        Description copied from interface: ApplicationState
        The consensus of the last batch of commands which the application was given
        Specified by:
        getLastCID in interface ApplicationState
        Returns:
        consensus of the last batch of commands which the application was given
      • getCheckpointCID

        public int getCheckpointCID()
      • getMessageBatch

        public CommandsInfo getMessageBatch​(int cid)
        Retrieves the specified batch of messages
        Parameters:
        cid - Consensus ID associated with the batch to be fetched
        Returns:
        The batch of messages associated with the batch correspondent consensus ID
      • getHashLogUpper

        public byte[] getHashLogUpper()
      • getHashLogLower

        public byte[] getHashLogLower()
      • getHashCheckpoint

        public byte[] getHashCheckpoint()