Package bftsmart.tom.core
Class ExecutionManager
- java.lang.Object
-
- bftsmart.tom.core.ExecutionManager
-
public final class ExecutionManager extends java.lang.Object
This 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 void
addForwarded(int cid, int replica)
void
addOutOfContextMessage(ConsensusMessage m)
Stores a message established as being out of context (a message that doesn't belong to current executing consensus).void
addToForward(int cid, int replica)
boolean
checkLimits(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.void
clearStopped()
Acceptor
getAcceptor()
Returns the acceptor role of the PaW algorithmConsensus
getConsensus(int cid)
Returns the specified consensusint
getCurrentLeader()
Get the current leaderProposer
getProposer()
java.util.Queue<ConsensusMessage>
getStoppedMsgs()
int[]
getToForward(int cid)
TOMLayer
getTOMLayer()
Returns the TOM layer associated with this execution managerboolean
hasBeenForwardedAlready(int cid, int replica)
boolean
hasMsgs()
boolean
isDecidable(int cid)
void
processOutOfContext(Consensus consensus)
void
processOutOfContextDecision(Consensus consensus)
Process a forwarded decision message that was received in a specific consensus instancevoid
processOutOfContextPropose(Consensus consensus)
boolean
receivedOutOfContextDecision(int cid)
boolean
receivedOutOfContextPropose(int cid)
Informs if there are messages till to be processed associated the specified consensusConsensus
removeConsensus(int id)
Removes a consensus from this managervoid
removeOutOfContexts(int id)
THIS IS JOAO'S CODE, FOR HANDLING THE STATE TRANSFERvoid
restart()
Restarts this execution managervoid
setNewLeader(int leader)
Set the current leadervoid
setTOMLayer(TOMLayer tom)
Sets the TOM layer associated with this execution managervoid
stop()
Stops this execution managerboolean
stopped()
java.lang.String
toString()
-
-
-
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:
toString
in 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)
-
-