Class 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 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 algorithm
        proposer - Proposer role of the PaW algorithm
        me - 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()
      • 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 epoch
        message - 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 class java.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)