Class TOMMessage

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

    public class TOMMessage
    extends SystemMessage
    implements java.io.Externalizable, java.lang.Comparable, java.lang.Cloneable
    This class represents a total ordered message
    See Also:
    Serialized Form
    • Field Detail

      • timestamp

        public transient long timestamp
      • seed

        public transient long seed
      • numOfNonces

        public transient int numOfNonces
      • destination

        public transient int destination
      • signed

        public transient boolean signed
      • receptionTime

        public transient long receptionTime
      • receptionTimestamp

        public transient long receptionTimestamp
      • timeout

        public transient boolean timeout
      • recvFromClient

        public transient boolean recvFromClient
      • isValid

        public transient boolean isValid
      • serializedMessage

        public transient byte[] serializedMessage
      • serializedMessageSignature

        public transient byte[] serializedMessageSignature
      • serializedMessageMAC

        public transient byte[] serializedMessageMAC
      • consensusStartTime

        public transient long consensusStartTime
      • proposeReceivedTime

        public transient long proposeReceivedTime
      • writeSentTime

        public transient long writeSentTime
      • acceptSentTime

        public transient long acceptSentTime
      • decisionTime

        public transient long decisionTime
      • deliveryTime

        public transient long deliveryTime
      • executedTime

        public transient long executedTime
      • alreadyProposed

        public transient boolean alreadyProposed
      • retry

        public transient int retry
    • Constructor Detail

      • TOMMessage

        public TOMMessage()
      • TOMMessage

        public TOMMessage​(int sender,
                          int session,
                          int sequence,
                          int operationId,
                          byte[] content,
                          int view,
                          TOMMessageType type)
        Creates a new instance of TOMMessage. This one has an operationId parameter used for FIFO executions
        Parameters:
        sender - The client id
        session - The session id of the sender
        sequence - The sequence number created based on the message type
        operationId - The operation sequence number disregarding message type
        content - The command to be executed
        view - The view in which the message was sent
        type - Ordered or Unordered request
    • Method Detail

      • getDebugInfo

        public DebugInfo getDebugInfo()
        Retrieves the debug info from the TOM layer
        Returns:
        The debug info from the TOM layer
      • setDebugInfo

        public void setDebugInfo​(DebugInfo info)
        Retrieves the debug info from the TOM layer
      • getSession

        public int getSession()
        Retrieves the session id of this message
        Returns:
        The session id of this message
      • getSequence

        public int getSequence()
        Retrieves the sequence number defined by the client
        Returns:
        The sequence number defined by the client
      • getOperationId

        public int getOperationId()
      • getViewID

        public int getViewID()
      • getId

        public int getId()
        Retrieves the ID for this message. It should be unique
        Returns:
        The ID for this message.
      • getContent

        public byte[] getContent()
        Retrieves the content of the message
        Returns:
        The content of the message
      • equals

        public boolean equals​(java.lang.Object o)
        Verifies if two TOMMessage are equal. For performance reasons, the method only verifies if the send and sequence are equal. Two TOMMessage are equal if they have the same sender, sequence number and content.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

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

        public void wExternal​(java.io.DataOutput out)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • rExternal

        public void rExternal​(java.io.DataInput in)
                       throws java.io.IOException,
                              java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • getSenderFromId

        public static int getSenderFromId​(int id)
        Retrieves the process ID of the sender given a message ID
        Parameters:
        id - Message ID
        Returns:
        Process ID of the sender
      • messageToBytes

        public static byte[] messageToBytes​(TOMMessage m)
      • bytesToMessage

        public static TOMMessage bytesToMessage​(byte[] b)
      • compareTo

        public int compareTo​(java.lang.Object o)
        Specified by:
        compareTo in interface java.lang.Comparable
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
      • setSender

        public void setSender​(int sender)
      • getReplyServer

        public int getReplyServer()
      • setReplyServer

        public void setReplyServer​(int replyServer)
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        This two methods implement the Externalizable interface --- only used for serialization of forwarded requests/replies when used for transferring ** replica application state ** that includes these. Not used for the total order multicast protocol or the client-server communication.
        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