Package bftsmart.tom.core.messages
Class TOMMessage
- java.lang.Object
-
- bftsmart.communication.SystemMessage
-
- bftsmart.tom.core.messages.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 Summary
Fields Modifier and Type Field Description longacceptSentTimebooleanalreadyProposedlongconsensusStartTimelongdecisionTimelongdeliveryTimeintdestinationlongexecutedTimebooleanisValidintnumOfNonceslongproposeReceivedTimelongreceptionTimelongreceptionTimestampbooleanrecvFromClientTOMMessagereplyintretrylongseedbyte[]serializedMessagebyte[]serializedMessageMACbyte[]serializedMessageSignaturebooleansignedbooleantimeoutlongtimestamplongwriteSentTime-
Fields inherited from class bftsmart.communication.SystemMessage
authenticated, sender
-
-
Constructor Summary
Constructors Constructor Description TOMMessage()TOMMessage(int sender, int session, int sequence, int operationId, byte[] content, int view, TOMMessageType type)Creates a new instance of TOMMessage.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TOMMessagebytesToMessage(byte[] b)java.lang.Objectclone()intcompareTo(java.lang.Object o)booleanequals(java.lang.Object o)Verifies if two TOMMessage are equal.byte[]getContent()Retrieves the content of the messageDebugInfogetDebugInfo()Retrieves the debug info from the TOM layerintgetId()Retrieves the ID for this message.intgetOperationId()intgetReplyServer()TOMMessageTypegetReqType()static intgetSenderFromId(int id)Retrieves the process ID of the sender given a message IDintgetSequence()Retrieves the sequence number defined by the clientintgetSession()Retrieves the session id of this messageintgetViewID()inthashCode()static byte[]messageToBytes(TOMMessage m)voidreadExternal(java.io.ObjectInput in)voidrExternal(java.io.DataInput in)voidsetDebugInfo(DebugInfo info)Retrieves the debug info from the TOM layervoidsetReplyServer(int replyServer)voidsetSender(int sender)java.lang.StringtoString()voidwExternal(java.io.DataOutput out)voidwriteExternal(java.io.ObjectOutput out)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.-
Methods inherited from class bftsmart.communication.SystemMessage
getSender
-
-
-
-
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
-
reply
public transient TOMMessage reply
-
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 idsession- The session id of the sendersequence- The sequence number created based on the message typeoperationId- The operation sequence number disregarding message typecontent- The command to be executedview- The view in which the message was senttype- 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()
-
getReqType
public TOMMessageType getReqType()
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.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.IOExceptionjava.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:
compareToin interfacejava.lang.Comparable
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.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.IOExceptionThis 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:
writeExternalin interfacejava.io.Externalizable- Overrides:
writeExternalin classSystemMessage- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Overrides:
readExternalin classSystemMessage- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-