Package bftsmart.consensus.messages
Class ConsensusMessage
- java.lang.Object
-
- bftsmart.communication.SystemMessage
-
- bftsmart.consensus.messages.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
-
-
Field Summary
-
Fields inherited from class bftsmart.communication.SystemMessage
authenticated, sender
-
-
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 belongsint
getNumber()
Returns the consensus ID of this messagejava.lang.String
getPaxosVerboseType()
Returns this message type as a verbose stringjava.lang.Object
getProof()
Returns the proof associated with a PROPOSE or COLLECT messageint
getType()
Returns this message typebyte[]
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 bftsmart.communication.SystemMessage
getSender
-
-
-
-
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.PROPOSEid
- Consensus's IDepoch
- Epoch timestampfrom
- This should be this process IDvalue
- 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.FREEZEid
- Consensus's consensus IDepoch
- Epoch timestampfrom
- This should be this process ID
-
-
Method Detail
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- 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
-
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 classjava.lang.Object
-
-