Package bftsmart.tom.leaderchange
Class LCManager
- java.lang.Object
-
- bftsmart.tom.leaderchange.LCManager
-
public class LCManager extends java.lang.ObjectThis class implements a manager of information related to the leader change protocol It also implements some predicates and methods necessary for the protocol in accordance to Cachin's 'Yet Another Visit to Paxos' (April 2011).
-
-
Constructor Summary
Constructors Constructor Description LCManager(TOMLayer tomLayer, ServerViewController SVController, java.security.MessageDigest md)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCollect(int regency, java.security.SignedObject signedCollect)Keep collect from an incoming SYNC messagevoidaddLastCID(int regency, CertifiedDecision lastCID)Keep last CID from an incoming SYNC messagevoidaddRequestsFromSTOP(TOMMessage[] requestsFromSTOP)This is meant to keep track of requests received in STOP messagesvoidaddStop(int regency, int pid)Keep information about an incoming STOP messagebooleanbinds(int timestamp, byte[] value, java.util.HashSet<CollectData> collects)The predicate "binds".booleancertifiedValue(int timestamp, byte[] value, java.util.HashSet<CollectData> collects)The predicate "certifiedValue".voidclearCurrentRequestTimedOut()Discard timed out requests in this replicavoidclearRequestsFromSTOP()Discard requests received in STOP messagesbyte[]getBindValue(java.util.HashSet<CollectData> collects)Return a value that is "bind", that is different from null, and with a timestamp greater or equal to zerojava.util.HashSet<java.security.SignedObject>getCollects(int regency)Get the set of collects related to a regencyintgetCollectsSize(int regency)Get the quantity of stored collect informationjava.util.List<TOMMessage>getCurrentRequestTimedOut()Get the timed out requests in this replicaintgetETS(int cid, java.util.Set<CollectData> collects)Gets the highest ETS associated with a consensus ID from the given collectsCertifiedDecisiongetHighestLastCID(int ts)Gets the highest valid last CID related to the given timestampjava.util.HashSet<CertifiedDecision>getLastCIDs(int regency)Get the set of last CIDs related to a regencyintgetLastCIDsSize(int regency)Get the quantity of stored last CID informationbyte[]getLastCIDValue(int regency, int cid)Returns the value of the specified last CID for a given regencyintgetLastReg()The current regencyintgetNewLeader()Deterministically elects a new leader, based current leader and membershipintgetNextReg()The next regencyjava.util.List<TOMMessage>getRequestsFromSTOP()Get the requests received in STOP messagesintgetStopsSize(int regency)Get the quantity of stored STOP informationbooleanhasValidProof(CertifiedDecision cDec)booleanquorumHighest(int timestamp, byte[] value, java.util.HashSet<CollectData> collects)The predicate "quorumHighest".voidremoveCollects(int regency)Discard collect information up to the given regencyvoidremoveLastCIDs(int regency)Discard last CID information up to the specified regencyvoidremoveStops(int regency)Discard information about STOP messages up to specified regencyjava.util.HashSet<CollectData>selectCollects(int regency, int cid)Fetchs a set of correctly signed and normalized collect data structuresjava.util.HashSet<CollectData>selectCollects(java.util.HashSet<java.security.SignedObject> signedObjects, int cid, int regency)Fetchs a set of correctly signed and normalized collect data structures from the specified original set of collectsvoidsetCollects(int regency, java.util.HashSet<java.security.SignedObject> colls)Defines the set of collects related to a regencyvoidsetCurrentRequestTimedOut(java.util.List<TOMMessage> currentRequestTimedOut)This is meant to keep track of timed out requests in this replicavoidsetLastCIDs(int regency, java.util.HashSet<CertifiedDecision> lasts)Defines the set of last CIDs related to a regencyvoidsetLastReg(int lastreg)Set the previous regencyvoidsetNewLeader(int leader)Informs the object of who is the current leadervoidsetNextReg(int nextreg)Set the next regencybooleansound(java.util.HashSet<CollectData> collects)The all-important predicate "sound".booleanunbound(java.util.HashSet<CollectData> collects)The predicate "unbound".
-
-
-
Constructor Detail
-
LCManager
public LCManager(TOMLayer tomLayer, ServerViewController SVController, java.security.MessageDigest md)
Constructor- Parameters:
reconfManager- The reconfiguration manager from TOM layermd- The message digest engine from TOM layer
-
-
Method Detail
-
getNewLeader
public int getNewLeader()
Deterministically elects a new leader, based current leader and membership- Returns:
- The new leader
-
setNewLeader
public void setNewLeader(int leader)
Informs the object of who is the current leader- Parameters:
leader- The current leader
-
setCurrentRequestTimedOut
public void setCurrentRequestTimedOut(java.util.List<TOMMessage> currentRequestTimedOut)
This is meant to keep track of timed out requests in this replica- Parameters:
currentRequestTimedOut- Timed out requests in this replica
-
getCurrentRequestTimedOut
public java.util.List<TOMMessage> getCurrentRequestTimedOut()
Get the timed out requests in this replica- Returns:
- timed out requests in this replica
-
clearCurrentRequestTimedOut
public void clearCurrentRequestTimedOut()
Discard timed out requests in this replica
-
addRequestsFromSTOP
public void addRequestsFromSTOP(TOMMessage[] requestsFromSTOP)
This is meant to keep track of requests received in STOP messages- Parameters:
requestsFromSTOP- Requests received in a STOP message
-
getRequestsFromSTOP
public java.util.List<TOMMessage> getRequestsFromSTOP()
Get the requests received in STOP messages- Returns:
- requests received in STOP messages
-
clearRequestsFromSTOP
public void clearRequestsFromSTOP()
Discard requests received in STOP messages
-
setLastReg
public void setLastReg(int lastreg)
Set the previous regency- Parameters:
lastreg- current regency
-
getLastReg
public int getLastReg()
The current regency- Returns:
- current regency
-
setNextReg
public void setNextReg(int nextreg)
Set the next regency- Parameters:
nextts- next regency
-
getNextReg
public int getNextReg()
The next regency- Returns:
- next regency
-
addStop
public void addStop(int regency, int pid)Keep information about an incoming STOP message- Parameters:
regency- the next regencypid- the process that sent the message
-
removeStops
public void removeStops(int regency)
Discard information about STOP messages up to specified regency- Parameters:
ts- timestamp up to which to discard messages
-
getStopsSize
public int getStopsSize(int regency)
Get the quantity of stored STOP information- Parameters:
regency- Regency to be considered- Returns:
- quantity of stored STOP information for given timestamp
-
addLastCID
public void addLastCID(int regency, CertifiedDecision lastCID)Keep last CID from an incoming SYNC message- Parameters:
regency- the current regencylastCID- the last CID data
-
removeLastCIDs
public void removeLastCIDs(int regency)
Discard last CID information up to the specified regency- Parameters:
regency- Regency up to which to discard information
-
getLastCIDsSize
public int getLastCIDsSize(int regency)
Get the quantity of stored last CID information- Parameters:
regency- regency to be considered- Returns:
- quantity of stored last CID information for given regency
-
getLastCIDs
public java.util.HashSet<CertifiedDecision> getLastCIDs(int regency)
Get the set of last CIDs related to a regency- Parameters:
regency- Regency for the last CID info- Returns:
- a set of last CID data
-
setLastCIDs
public void setLastCIDs(int regency, java.util.HashSet<CertifiedDecision> lasts)Defines the set of last CIDs related to a regency- Parameters:
regency- Regency for the last CID infolasts- a set of last CID data
-
addCollect
public void addCollect(int regency, java.security.SignedObject signedCollect)Keep collect from an incoming SYNC message- Parameters:
ts- the current regencysignedCollect- the signed collect data
-
removeCollects
public void removeCollects(int regency)
Discard collect information up to the given regency- Parameters:
regency- Regency up to which to discard information
-
getCollectsSize
public int getCollectsSize(int regency)
Get the quantity of stored collect information- Parameters:
regency- Regency to be considered- Returns:
- quantity of stored collect information for given regency
-
getCollects
public java.util.HashSet<java.security.SignedObject> getCollects(int regency)
Get the set of collects related to a regency- Parameters:
regency- Regency for collects- Returns:
- a set of collect data
-
setCollects
public void setCollects(int regency, java.util.HashSet<java.security.SignedObject> colls)Defines the set of collects related to a regency- Parameters:
regency- Regency for the last CID infocolls- a set of collect data
-
sound
public boolean sound(java.util.HashSet<CollectData> collects)
The all-important predicate "sound". This method must received a set of collects that were filtered using the method selectCollects()- Parameters:
collects- the collect data to which to apply the predicate.- Returns:
- See Cachin's 'Yet Another Visit to Paxos' (April 2011), page 11 In addition, see pages 252 and 253 from "Introduction to Reliable and Secure Distributed Programming"
-
binds
public boolean binds(int timestamp, byte[] value, java.util.HashSet<CollectData> collects)The predicate "binds". This method must received a set of collects that were filtered using the method selectCollects()- Parameters:
timestamp- the timestamp to search forvalue- the value to search forcollects- the collect data to which to apply the predicate.- Returns:
- See Cachin's 'Yet Another Visit to Paxos' (April 2011), page 11 In addition, see pages 252 and 253 from "Introduction to Reliable and Secure Distributed Programming"
-
getBindValue
public byte[] getBindValue(java.util.HashSet<CollectData> collects)
Return a value that is "bind", that is different from null, and with a timestamp greater or equal to zero- Parameters:
collects- Set of collects from which to determine the value- Returns:
- The bind value See Cachin's 'Yet Another Visit to Paxos' (April 2011), page 11 Also, see pages 252 and 253 from "Introduction to Reliable and Secure Distributed Programming"
-
unbound
public boolean unbound(java.util.HashSet<CollectData> collects)
The predicate "unbound". This method must received a set of collects that were filtered using the method selectCollects()- Parameters:
collects- the collect data to which to apply the predicate.- Returns:
- See Cachin's 'Yet Another Visit to Paxos' (April 2011), page 11 In addition, see page 253 from "Introduction to Reliable and Secure Distributed Programming"
-
quorumHighest
public boolean quorumHighest(int timestamp, byte[] value, java.util.HashSet<CollectData> collects)The predicate "quorumHighest". This method must received a set of collects that were filtered using the method selectCollects()- Parameters:
timestamp- the timestamp to search forvalue- the value to search forcollects- the collect data to which to apply the predicate.- Returns:
- See Cachin's 'Yet Another Visit to Paxos' (April 2011), pages 10-11 In addition, see pages 252 and 253 from "Introduction to Reliable and Secure Distributed Programming"
-
certifiedValue
public boolean certifiedValue(int timestamp, byte[] value, java.util.HashSet<CollectData> collects)The predicate "certifiedValue". This method must received a set of collects that were filtered using the method selectCollects()- Parameters:
timestamp- the timestamp to search forvalue- the value to search forcollects- the collect data to which to apply the predicate.- Returns:
- See Cachin's 'Yet Another Visit to Paxos' (April 2011), page 11 In addition, see page 253 from "Introduction to Reliable and Secure Distributed Programming"
-
selectCollects
public java.util.HashSet<CollectData> selectCollects(int regency, int cid)
Fetchs a set of correctly signed and normalized collect data structures- Parameters:
regency- the regency from which the collects were storedcid- the CID to which to normalize the collects- Returns:
- a set of correctly signed and normalized collect data structures
-
selectCollects
public java.util.HashSet<CollectData> selectCollects(java.util.HashSet<java.security.SignedObject> signedObjects, int cid, int regency)
Fetchs a set of correctly signed and normalized collect data structures from the specified original set of collects- Parameters:
signedObjects- original set of signed collectscid- the CID to which to normalize the collects- Returns:
- a set of correctly signed and normalized collect data structures
-
getHighestLastCID
public CertifiedDecision getHighestLastCID(int ts)
Gets the highest valid last CID related to the given timestamp- Parameters:
ts- the timestamp- Returns:
- -1 if there is no such CID, otherwise returns the highest valid last CID
-
hasValidProof
public boolean hasValidProof(CertifiedDecision cDec)
-
getLastCIDValue
public byte[] getLastCIDValue(int regency, int cid)Returns the value of the specified last CID for a given regency- Parameters:
regency- the related regencycid- the last CID- Returns:
- null if there is no such CID or is invalid, otherwise returns the value
-
getETS
public int getETS(int cid, java.util.Set<CollectData> collects)Gets the highest ETS associated with a consensus ID from the given collects- Parameters:
cid- The consensus IDcollects- The collects from the other replicas- Returns:
- The highest ETS
-
-