Package bftsmart.consensus
Class Epoch
- java.lang.Object
-
- bftsmart.consensus.Epoch
-
- All Implemented Interfaces:
java.io.Serializable
public class Epoch extends java.lang.Object implements java.io.Serializable
This class stands for a consensus epoch, as described in Cachin's 'Yet Another Visit to Paxos' (April 2011)- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description boolean
decisionRequested
TOMMessage[]
deserializedPropValue
java.util.HashSet<ConsensusMessage>
proof
byte[]
propValue
byte[]
propValueHash
-
Constructor Summary
Constructors Constructor Description Epoch(ServerViewController controller, Consensus parent, int timestamp)
Creates a new instance of Epoch for acceptors
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptCreated()
Indicate that the consensus instance already created its ACCEPT messagevoid
acceptSent()
Indicate that the consensus instance already sent its ACCEPT messagevoid
addToProof(ConsensusMessage pm)
void
clear()
Clear all epoch info.int
countAccept(byte[] value)
Retrieves the amount of replicas from which this process accepted a specified valueint[]
countAcceptFrom(byte[] value)
Retrieves th replicas from which this process accepted a specified valueint
countWrite(byte[] value)
Retrieves the amount of replicas from which this process received a WRITE valueboolean
equals(java.lang.Object o)
ConsensusMessage
fetchAccept()
Fetch the speculative ACCEPT message.byte[][]
getAccept()
Retrieves all accepted values from all replicasbyte[]
getAccept(int acceptor)
Retrieves the accepted value from the specified replicaConsensus
getConsensus()
Retrieves this epoch's consensusjava.util.Set<ConsensusMessage>
getProof()
int
getTimestamp()
Retrieves this epoch's timestampbyte[][]
getWrite()
Retrieves all WRITE value from all replicasbyte[]
getWrite(int acceptor)
Retrives the WRITE value from the specified replicaboolean
isAcceptCreated()
Indicates if the consensus instance already created its ACCEPT messageboolean
isAcceptSent()
Indicates if the consensus instance already sent its ACCEPT messageboolean
isAcceptSetted(int acceptor)
Informs if there is a accepted value from a replicaboolean
isRemoved()
Informs if this epoch was removed from its consensus instanceboolean
isWriteSent()
Indicates if the consensus instance already sent its WRITE messageboolean
isWriteSetted(int acceptor)
Informs if there is a WRITE value from a replicavoid
setAccept(int acceptor, byte[] value)
Sets the accepted value from the specified replicavoid
setAcceptMsg(ConsensusMessage acceptMsg)
Set the speculative ACCEPT messagevoid
setProof(java.util.HashSet<ConsensusMessage> proof)
void
setRemoved()
Set this epoch as removed from its consensus instancevoid
setWrite(int acceptor, byte[] value)
Sets the WRITE value from the specified replicajava.lang.String
toString()
Print epoch information.void
writeSent()
Indicate that the consensus instance already sent its WRITE message
-
-
-
Field Detail
-
propValue
public byte[] propValue
-
deserializedPropValue
public TOMMessage[] deserializedPropValue
-
propValueHash
public byte[] propValueHash
-
proof
public java.util.HashSet<ConsensusMessage> proof
-
decisionRequested
public boolean decisionRequested
-
-
Constructor Detail
-
Epoch
public Epoch(ServerViewController controller, Consensus parent, int timestamp)
Creates a new instance of Epoch for acceptors- Parameters:
controller
-parent
- Consensus to which this epoch belongstimestamp
- Timestamp of the epoch
-
-
Method Detail
-
setRemoved
public void setRemoved()
Set this epoch as removed from its consensus instance
-
isRemoved
public boolean isRemoved()
Informs if this epoch was removed from its consensus instance- Returns:
- True if it is removed, false otherwise
-
addToProof
public void addToProof(ConsensusMessage pm)
-
setProof
public void setProof(java.util.HashSet<ConsensusMessage> proof)
-
getProof
public java.util.Set<ConsensusMessage> getProof()
-
getTimestamp
public int getTimestamp()
Retrieves this epoch's timestamp- Returns:
- This epoch's timestamp
-
getConsensus
public Consensus getConsensus()
Retrieves this epoch's consensus- Returns:
- This epoch's consensus
-
isWriteSetted
public boolean isWriteSetted(int acceptor)
Informs if there is a WRITE value from a replica- Parameters:
acceptor
- The replica ID- Returns:
- True if there is a WRITE value from a replica, false otherwise
-
isAcceptSetted
public boolean isAcceptSetted(int acceptor)
Informs if there is a accepted value from a replica- Parameters:
acceptor
- The replica ID- Returns:
- True if there is a accepted value from a replica, false otherwise
-
getWrite
public byte[] getWrite(int acceptor)
Retrives the WRITE value from the specified replica- Parameters:
acceptor
- The replica ID- Returns:
- The value from the specified replica
-
getWrite
public byte[][] getWrite()
Retrieves all WRITE value from all replicas- Returns:
- The values from all replicas
-
setWrite
public void setWrite(int acceptor, byte[] value)
Sets the WRITE value from the specified replica- Parameters:
acceptor
- The replica IDvalue
- The valuefrom the specified replica
-
getAccept
public byte[] getAccept(int acceptor)
Retrieves the accepted value from the specified replica- Parameters:
acceptor
- The replica ID- Returns:
- The value accepted from the specified replica
-
getAccept
public byte[][] getAccept()
Retrieves all accepted values from all replicas- Returns:
- The values accepted from all replicas
-
setAccept
public void setAccept(int acceptor, byte[] value)
Sets the accepted value from the specified replica- Parameters:
acceptor
- The replica IDvalue
- The value accepted from the specified replica
-
countWrite
public int countWrite(byte[] value)
Retrieves the amount of replicas from which this process received a WRITE value- Parameters:
value
- The value in question- Returns:
- Amount of replicas from which this process received the specified value
-
countAccept
public int countAccept(byte[] value)
Retrieves the amount of replicas from which this process accepted a specified value- Parameters:
value
- The value in question- Returns:
- Amount of replicas from which this process accepted the specified value
-
countAcceptFrom
public int[] countAcceptFrom(byte[] value)
Retrieves th replicas from which this process accepted a specified value- Parameters:
value
- The value in question- Returns:
- replicas from which this process accepted the specified value
-
writeSent
public void writeSent()
Indicate that the consensus instance already sent its WRITE message
-
acceptSent
public void acceptSent()
Indicate that the consensus instance already sent its ACCEPT message
-
acceptCreated
public void acceptCreated()
Indicate that the consensus instance already created its ACCEPT message
-
isWriteSent
public boolean isWriteSent()
Indicates if the consensus instance already sent its WRITE message- Returns:
- true if WRITE was indicated as sent, false otherwise
-
isAcceptSent
public boolean isAcceptSent()
Indicates if the consensus instance already sent its ACCEPT message- Returns:
- true if ACCEPT was indicated as sent, false otherwise
-
isAcceptCreated
public boolean isAcceptCreated()
Indicates if the consensus instance already created its ACCEPT message- Returns:
- true if ACCEPT was indicated as created, false otherwise
-
setAcceptMsg
public void setAcceptMsg(ConsensusMessage acceptMsg)
Set the speculative ACCEPT message- Parameters:
acceptMsg
- The speculative ACCEPT message
-
fetchAccept
public ConsensusMessage fetchAccept()
Fetch the speculative ACCEPT message. This method blocks until such message is set with setAcceptMsg(...);- Returns:
- The speculative ACCEPT message
-
toString
public java.lang.String toString()
Print epoch information.- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
clear
public void clear()
Clear all epoch info.
-
-