Class ConsensusMessage

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

    public class ConsensusMessage
    extends SystemMessage
    This class represents a message used in a epoch of a consensus instance.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ConsensusMessage()
      Creates a consensus message.
      ConsensusMessage​(int type, int id, int epoch, int from)
      Creates a consensus message.
      ConsensusMessage​(int paxosType, int id, int epoch, int from, byte[] value)
      Creates a consensus message.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getEpoch()
      Retrieves the epoch number to which this message belongs
      int getNumber()
      Returns the consensus ID of this message
      java.lang.String getPaxosVerboseType()
      Returns this message type as a verbose string
      java.lang.Object getProof()
      Returns the proof associated with a PROPOSE or COLLECT message
      int getType()
      Returns this message type
      byte[] getValue()
      Retrieves the value contained in the message.
      void readExternal​(java.io.ObjectInput in)  
      void setProof​(java.lang.Object proof)  
      java.lang.String toString()  
      void writeExternal​(java.io.ObjectOutput out)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ConsensusMessage

        public ConsensusMessage()
        Creates a consensus message. Not used. TODO: How about making it private?
      • ConsensusMessage

        public ConsensusMessage​(int paxosType,
                                int id,
                                int epoch,
                                int from,
                                byte[] value)
        Creates a consensus message. Used by the message factory to create a COLLECT or PROPOSE message TODO: How about removing the modifier, to make it visible just within the package?
        Parameters:
        paxosType - This should be MessageFactory.COLLECT or MessageFactory.PROPOSE
        id - Consensus's ID
        epoch - Epoch timestamp
        from - This should be this process ID
        value - This should be null if its a COLLECT message, or the proposed value if it is a PROPOSE message
      • ConsensusMessage

        public ConsensusMessage​(int type,
                                int id,
                                int epoch,
                                int from)
        Creates a consensus message. Used by the message factory to create a FREEZE message TODO: How about removing the modifier, to make it visible just within the package?
        Parameters:
        type - This should be MessageFactory.FREEZE
        id - Consensus's consensus ID
        epoch - Epoch timestamp
        from - This should be this process ID
    • Method Detail

      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Overrides:
        writeExternal in class SystemMessage
        Throws:
        java.io.IOException
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Specified by:
        readExternal in interface java.io.Externalizable
        Overrides:
        readExternal in class SystemMessage
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • getEpoch

        public int getEpoch()
        Retrieves the epoch number to which this message belongs
        Returns:
        Epoch to which this message belongs
      • getValue

        public byte[] getValue()
        Retrieves the value contained in the message.
        Returns:
        The value
      • setProof

        public void setProof​(java.lang.Object proof)
      • getProof

        public java.lang.Object getProof()
        Returns the proof associated with a PROPOSE or COLLECT message
        Returns:
        The proof
      • getNumber

        public int getNumber()
        Returns the consensus ID of this message
        Returns:
        Consensus ID of this message
      • getType

        public int getType()
        Returns this message type
        Returns:
        This message type
      • getPaxosVerboseType

        public java.lang.String getPaxosVerboseType()
        Returns this message type as a verbose string
        Returns:
        Message type
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object