Package bftsmart.tom.core
Class ExecutionManager
- java.lang.Object
-
- bftsmart.tom.core.ExecutionManager
-
public final class ExecutionManager extends java.lang.ObjectThis class manages consensus instances. It can have several epochs if there were problems during consensus.
-
-
Constructor Summary
Constructors Constructor Description ExecutionManager(ServerViewController controller, Acceptor acceptor, Proposer proposer, int me)Creates a new instance of ExecutionManager
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddForwarded(int cid, int replica)voidaddOutOfContextMessage(ConsensusMessage m)Stores a message established as being out of context (a message that doesn't belong to current executing consensus).voidaddToForward(int cid, int replica)booleancheckLimits(ConsensusMessage msg)Checks if this message can execute now.int[]checkRequestDecision(Epoch epoch, ConsensusMessage message)This method checks if a decision should be requested from other replicas.voidclearStopped()AcceptorgetAcceptor()Returns the acceptor role of the PaW algorithmConsensusgetConsensus(int cid)Returns the specified consensusintgetCurrentLeader()Get the current leaderProposergetProposer()java.util.Queue<ConsensusMessage>getStoppedMsgs()int[]getToForward(int cid)TOMLayergetTOMLayer()Returns the TOM layer associated with this execution managerbooleanhasBeenForwardedAlready(int cid, int replica)booleanhasMsgs()booleanisDecidable(int cid)voidprocessOutOfContext(Consensus consensus)voidprocessOutOfContextDecision(Consensus consensus)Process a forwarded decision message that was received in a specific consensus instancevoidprocessOutOfContextPropose(Consensus consensus)booleanreceivedOutOfContextDecision(int cid)booleanreceivedOutOfContextPropose(int cid)Informs if there are messages till to be processed associated the specified consensusConsensusremoveConsensus(int id)Removes a consensus from this managervoidremoveOutOfContexts(int id)THIS IS JOAO'S CODE, FOR HANDLING THE STATE TRANSFERvoidrestart()Restarts this execution managervoidsetNewLeader(int leader)Set the current leadervoidsetTOMLayer(TOMLayer tom)Sets the TOM layer associated with this execution managervoidstop()Stops this execution managerbooleanstopped()java.lang.StringtoString()
-
-
-
Constructor Detail
-
ExecutionManager
public ExecutionManager(ServerViewController controller, Acceptor acceptor, Proposer proposer, int me)
Creates a new instance of ExecutionManager- Parameters:
controller-acceptor- Acceptor role of the PaW algorithmproposer- Proposer role of the PaW algorithmme- This process ID
-
-
Method Detail
-
setNewLeader
public void setNewLeader(int leader)
Set the current leader- Parameters:
leader- Current leader
-
getCurrentLeader
public int getCurrentLeader()
Get the current leader- Returns:
- Current leader
-
setTOMLayer
public void setTOMLayer(TOMLayer tom)
Sets the TOM layer associated with this execution manager- Parameters:
tom- The TOM layer associated with this execution manager
-
getTOMLayer
public TOMLayer getTOMLayer()
Returns the TOM layer associated with this execution manager- Returns:
- The TOM layer associated with this execution manager
-
getAcceptor
public Acceptor getAcceptor()
Returns the acceptor role of the PaW algorithm- Returns:
- The acceptor role of the PaW algorithm
-
getProposer
public Proposer getProposer()
-
stopped
public boolean stopped()
-
hasMsgs
public boolean hasMsgs()
-
getStoppedMsgs
public java.util.Queue<ConsensusMessage> getStoppedMsgs()
-
clearStopped
public void clearStopped()
-
stop
public void stop()
Stops this execution manager
-
restart
public void restart()
Restarts this execution manager
-
checkLimits
public final boolean checkLimits(ConsensusMessage msg)
Checks if this message can execute now. If it is not possible, it is stored in outOfContextMessages- Parameters:
msg- the received message- Returns:
- true in case the message can be executed, false otherwise
-
receivedOutOfContextPropose
public boolean receivedOutOfContextPropose(int cid)
Informs if there are messages till to be processed associated the specified consensus- Parameters:
cid- The ID for the consensus in question- Returns:
- True if there are still messages to be processed, false otherwise
-
receivedOutOfContextDecision
public boolean receivedOutOfContextDecision(int cid)
-
removeConsensus
public Consensus removeConsensus(int id)
Removes a consensus from this manager- Parameters:
id- ID of the consensus to be removed- Returns:
- The consensus that was removed
-
removeOutOfContexts
public void removeOutOfContexts(int id)
THIS IS JOAO'S CODE, FOR HANDLING THE STATE TRANSFER
-
getConsensus
public Consensus getConsensus(int cid)
Returns the specified consensus- Parameters:
cid- ID of the consensus to be returned- Returns:
- The consensus specified
-
isDecidable
public boolean isDecidable(int cid)
-
processOutOfContextPropose
public void processOutOfContextPropose(Consensus consensus)
-
processOutOfContextDecision
public void processOutOfContextDecision(Consensus consensus)
Process a forwarded decision message that was received in a specific consensus instance- Parameters:
consensus- consensus instance
-
processOutOfContext
public void processOutOfContext(Consensus consensus)
-
addOutOfContextMessage
public void addOutOfContextMessage(ConsensusMessage m)
Stores a message established as being out of context (a message that doesn't belong to current executing consensus).- Parameters:
m- Out of context message to be stored
-
checkRequestDecision
public int[] checkRequestDecision(Epoch epoch, ConsensusMessage message)
This method checks if a decision should be requested from other replicas. The result will be either "null" that is if is not necessary to ask others about a decision yet, or an array containing the target ids of replicas which are being asked to forward a decision.- Parameters:
epoch- the current epochmessage- the last ACCEPT received- Returns:
- array of targets to ask for a decision or null if it's not necessary
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
addToForward
public void addToForward(int cid, int replica)
-
getToForward
public int[] getToForward(int cid)
-
addForwarded
public void addForwarded(int cid, int replica)
-
hasBeenForwardedAlready
public boolean hasBeenForwardedAlready(int cid, int replica)
-
-