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 long
acceptSentTime
boolean
alreadyProposed
long
consensusStartTime
long
decisionTime
long
deliveryTime
int
destination
long
executedTime
boolean
isValid
int
numOfNonces
long
proposeReceivedTime
long
receptionTime
long
receptionTimestamp
boolean
recvFromClient
TOMMessage
reply
int
retry
long
seed
byte[]
serializedMessage
byte[]
serializedMessageMAC
byte[]
serializedMessageSignature
boolean
signed
boolean
timeout
long
timestamp
long
writeSentTime
-
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 TOMMessage
bytesToMessage(byte[] b)
java.lang.Object
clone()
int
compareTo(java.lang.Object o)
boolean
equals(java.lang.Object o)
Verifies if two TOMMessage are equal.byte[]
getContent()
Retrieves the content of the messageDebugInfo
getDebugInfo()
Retrieves the debug info from the TOM layerint
getId()
Retrieves the ID for this message.int
getOperationId()
int
getReplyServer()
TOMMessageType
getReqType()
static int
getSenderFromId(int id)
Retrieves the process ID of the sender given a message IDint
getSequence()
Retrieves the sequence number defined by the clientint
getSession()
Retrieves the session id of this messageint
getViewID()
int
hashCode()
static byte[]
messageToBytes(TOMMessage m)
void
readExternal(java.io.ObjectInput in)
void
rExternal(java.io.DataInput in)
void
setDebugInfo(DebugInfo info)
Retrieves the debug info from the TOM layervoid
setReplyServer(int replyServer)
void
setSender(int sender)
java.lang.String
toString()
void
wExternal(java.io.DataOutput out)
void
writeExternal(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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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.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 interfacejava.lang.Comparable
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Overrides:
clone
in 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.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 interfacejava.io.Externalizable
- Overrides:
writeExternal
in classSystemMessage
- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Overrides:
readExternal
in classSystemMessage
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
-