Class LCManager


  • public class LCManager
    extends java.lang.Object
    This 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).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCollect​(int regency, java.security.SignedObject signedCollect)
      Keep collect from an incoming SYNC message
      void addLastCID​(int regency, CertifiedDecision lastCID)
      Keep last CID from an incoming SYNC message
      void addRequestsFromSTOP​(TOMMessage[] requestsFromSTOP)
      This is meant to keep track of requests received in STOP messages
      void addStop​(int regency, int pid)
      Keep information about an incoming STOP message
      boolean binds​(int timestamp, byte[] value, java.util.HashSet<CollectData> collects)
      The predicate "binds".
      boolean certifiedValue​(int timestamp, byte[] value, java.util.HashSet<CollectData> collects)
      The predicate "certifiedValue".
      void clearCurrentRequestTimedOut()
      Discard timed out requests in this replica
      void clearRequestsFromSTOP()
      Discard requests received in STOP messages
      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
      java.util.HashSet<java.security.SignedObject> getCollects​(int regency)
      Get the set of collects related to a regency
      int getCollectsSize​(int regency)
      Get the quantity of stored collect information
      java.util.List<TOMMessage> getCurrentRequestTimedOut()
      Get the timed out requests in this replica
      int getETS​(int cid, java.util.Set<CollectData> collects)
      Gets the highest ETS associated with a consensus ID from the given collects
      CertifiedDecision getHighestLastCID​(int ts)
      Gets the highest valid last CID related to the given timestamp
      java.util.HashSet<CertifiedDecision> getLastCIDs​(int regency)
      Get the set of last CIDs related to a regency
      int getLastCIDsSize​(int regency)
      Get the quantity of stored last CID information
      byte[] getLastCIDValue​(int regency, int cid)
      Returns the value of the specified last CID for a given regency
      int getLastReg()
      The current regency
      int getNewLeader()
      Deterministically elects a new leader, based current leader and membership
      int getNextReg()
      The next regency
      java.util.List<TOMMessage> getRequestsFromSTOP()
      Get the requests received in STOP messages
      int getStopsSize​(int regency)
      Get the quantity of stored STOP information
      boolean hasValidProof​(CertifiedDecision cDec)  
      boolean quorumHighest​(int timestamp, byte[] value, java.util.HashSet<CollectData> collects)
      The predicate "quorumHighest".
      void removeCollects​(int regency)
      Discard collect information up to the given regency
      void removeLastCIDs​(int regency)
      Discard last CID information up to the specified regency
      void removeStops​(int regency)
      Discard information about STOP messages up to specified regency
      java.util.HashSet<CollectData> selectCollects​(int regency, int cid)
      Fetchs a set of correctly signed and normalized collect data structures
      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
      void setCollects​(int regency, java.util.HashSet<java.security.SignedObject> colls)
      Defines the set of collects related to a regency
      void setCurrentRequestTimedOut​(java.util.List<TOMMessage> currentRequestTimedOut)
      This is meant to keep track of timed out requests in this replica
      void setLastCIDs​(int regency, java.util.HashSet<CertifiedDecision> lasts)
      Defines the set of last CIDs related to a regency
      void setLastReg​(int lastreg)
      Set the previous regency
      void setNewLeader​(int leader)
      Informs the object of who is the current leader
      void setNextReg​(int nextreg)
      Set the next regency
      boolean sound​(java.util.HashSet<CollectData> collects)
      The all-important predicate "sound".
      boolean unbound​(java.util.HashSet<CollectData> collects)
      The predicate "unbound".
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LCManager

        public LCManager​(TOMLayer tomLayer,
                         ServerViewController SVController,
                         java.security.MessageDigest md)
        Constructor
        Parameters:
        reconfManager - The reconfiguration manager from TOM layer
        md - 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 regency
        pid - 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 regency
        lastCID - 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 info
        lasts - 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 regency
        signedCollect - 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 info
        colls - 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 for
        value - the value to search for
        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"
      • 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 for
        value - the value to search for
        collects - 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 for
        value - the value to search for
        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"
      • 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 stored
        cid - 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 collects
        cid - 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
      • getLastCIDValue

        public byte[] getLastCIDValue​(int regency,
                                      int cid)
        Returns the value of the specified last CID for a given regency
        Parameters:
        regency - the related regency
        cid - 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 ID
        collects - The collects from the other replicas
        Returns:
        The highest ETS