Package bftsmart.tom

Class MessageContext

  • All Implemented Interfaces:
    java.io.Serializable

    public class MessageContext
    extends java.lang.Object
    implements java.io.Serializable
    This class represents the whole context of a request ordered in the system. It stores all informations regarding the message sent by the client, as well as the consensus instance in which it was ordered.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean readOnly  
    • Constructor Summary

      Constructors 
      Constructor Description
      MessageContext​(int sender, int viewID, TOMMessageType type, int session, int sequence, int operationId, int replyServer, byte[] signature, long timestamp, int numOfNonces, long seed, int regency, int leader, int consensusId, java.util.Set<ConsensusMessage> proof, TOMMessage firstInBatch, boolean noOp)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getConsensusId()
      Returns the ID of the consensus in which this request was ordered (-1 if readonly).
      TOMMessage getFirstInBatch()
      Returns the first request in the ordered batch
      int getLeader()
      Returns the id of the leader replica in which this message was ordered (-1 if readonly).
      byte[] getNonces()
      Returns the nonces as generated by the leader
      int getNumOfNonces()
      Returns the number of nonces as generated by the leader
      int getOperationId()
      Returns the operation ID
      java.util.Set<ConsensusMessage> getProof()
      Returns the proof for the consensus.
      int getRegency()
      Returns the current regency in which the message was ordered.
      int getReplyServer()
      Returns the ID of the server expected to send a non-hashed reply when the clients sends an unordered hashed request.
      long getSeed()
      Returns the seed as generated by the leader
      int getSender()
      Returns the ID of the client that sent the message
      int getSequence()
      Returns the request's sequence number
      int getSession()
      Returns the client's session
      byte[] getSignature()
      Returns the client's signature.
      long getTimestamp()
      Returns the timestamp as generated by the leader
      TOMMessageType getType()
      Returns the request type
      int getViewID()
      Returns the view ID
      boolean isLastInBatch()
      Returns the last request in the ordered batch
      boolean isNoOp()
      Returns true if the consensus instance has no operations to deliver to the application
      TOMMessage recreateTOMMessage​(byte[] content)
      Generates a TOMMessage for its associated requests using the new info that it now supports since the previous commit.
      void setLastInBatch()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • readOnly

        public boolean readOnly
    • Constructor Detail

      • MessageContext

        public MessageContext​(int sender,
                              int viewID,
                              TOMMessageType type,
                              int session,
                              int sequence,
                              int operationId,
                              int replyServer,
                              byte[] signature,
                              long timestamp,
                              int numOfNonces,
                              long seed,
                              int regency,
                              int leader,
                              int consensusId,
                              java.util.Set<ConsensusMessage> proof,
                              TOMMessage firstInBatch,
                              boolean noOp)
        Constructor
        Parameters:
        sender - The sender ID
        viewID - The view ID
        type - The request type
        session - Client's session
        sequence - Request's sequence number
        operationId - The operation ID
        replyServer - ID of the server expected to send a non-hashed reply when the clients sends an unordered hashed request.
        signature - Client's signature.
        timestamp - The timestamp as generated by the leader
        numOfNonces - The nonces as generated by the leader
        seed - The seed as generated by the leader
        regency - The current regency in which the message was ordered.
        leader - The leader with which the batch was decided
        consensusId - The ID of the consensus in which this request was ordered
        proof - The proof for the consensus
        firstInBatch - The first request in the ordered batch
        noOp - true if the consensus instance has no operations to deliver to the application
    • Method Detail

      • getViewID

        public int getViewID()
        Returns the view ID
        Returns:
        The view ID
      • getType

        public TOMMessageType getType()
        Returns the request type
        Returns:
        The request type
      • getSession

        public int getSession()
        Returns the client's session
        Returns:
        Client's session
      • getSequence

        public int getSequence()
        Returns the request's sequence number
        Returns:
        Request's sequence number
      • getOperationId

        public int getOperationId()
        Returns the operation ID
        Returns:
        The operation ID
      • getReplyServer

        public int getReplyServer()
        Returns the ID of the server expected to send a non-hashed reply when the clients sends an unordered hashed request.
        Returns:
        ID of the server expected to send a non-hashed reply when the clients sends an unordered hashed request.
      • getSignature

        public byte[] getSignature()
        Returns the client's signature.
        Returns:
        Client's signature.
      • getSender

        public int getSender()
        Returns the ID of the client that sent the message
        Returns:
        The sender ID
      • getTimestamp

        public long getTimestamp()
        Returns the timestamp as generated by the leader
        Returns:
        The timestamp as generated by the leader
      • getNonces

        public byte[] getNonces()
        Returns the nonces as generated by the leader
        Returns:
        The nonces as generated by the leader
      • getNumOfNonces

        public int getNumOfNonces()
        Returns the number of nonces as generated by the leader
        Returns:
        the number of nonces
      • getSeed

        public long getSeed()
        Returns the seed as generated by the leader
        Returns:
        The seed as generated by the leader
      • getConsensusId

        public int getConsensusId()
        Returns the ID of the consensus in which this request was ordered (-1 if readonly).
        Returns:
        The ID of the consensus in which this request was ordered
      • getLeader

        public int getLeader()
        Returns the id of the leader replica in which this message was ordered (-1 if readonly).
        Returns:
        The leader with which the batch was decided
      • getProof

        public java.util.Set<ConsensusMessage> getProof()
        Returns the proof for the consensus.
        Returns:
        The proof for the consensus
      • getRegency

        public int getRegency()
        Returns the current regency in which the message was ordered.
        Returns:
        The current regency in which the message was ordered.
      • getFirstInBatch

        public TOMMessage getFirstInBatch()
        Returns the first request in the ordered batch
        Returns:
        The first request in the ordered batch
      • setLastInBatch

        public void setLastInBatch()
      • isLastInBatch

        public boolean isLastInBatch()
        Returns the last request in the ordered batch
        Returns:
        The last request in the ordered batch
      • isNoOp

        public boolean isNoOp()
        Returns true if the consensus instance has no operations to deliver to the application
        Returns:
        true if the consensus instance has no operations to deliver to the application
      • recreateTOMMessage

        public TOMMessage recreateTOMMessage​(byte[] content)
        Generates a TOMMessage for its associated requests using the new info that it now supports since the previous commit. It is assumed that the byte array passed to this method is the serialized request associated to the original TOMMessage.
        Parameters:
        content - Serialized request associated to the original TOMMessage.
        Returns:
        A TOMMessage object that is equal to the original object issued by the client