Class Epoch

  • All Implemented Interfaces:
    java.io.Serializable

    public class Epoch
    extends java.lang.Object
    implements java.io.Serializable
    This class stands for a consensus epoch, as described in Cachin's 'Yet Another Visit to Paxos' (April 2011)
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Epoch​(ServerViewController controller, Consensus parent, int timestamp)
      Creates a new instance of Epoch for acceptors
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void acceptCreated()
      Indicate that the consensus instance already created its ACCEPT message
      void acceptSent()
      Indicate that the consensus instance already sent its ACCEPT message
      void addToProof​(ConsensusMessage pm)  
      void clear()
      Clear all epoch info.
      int countAccept​(byte[] value)
      Retrieves the amount of replicas from which this process accepted a specified value
      int[] countAcceptFrom​(byte[] value)
      Retrieves th replicas from which this process accepted a specified value
      int countWrite​(byte[] value)
      Retrieves the amount of replicas from which this process received a WRITE value
      boolean equals​(java.lang.Object o)  
      ConsensusMessage fetchAccept()
      Fetch the speculative ACCEPT message.
      byte[][] getAccept()
      Retrieves all accepted values from all replicas
      byte[] getAccept​(int acceptor)
      Retrieves the accepted value from the specified replica
      Consensus getConsensus()
      Retrieves this epoch's consensus
      java.util.Set<ConsensusMessage> getProof()  
      int getTimestamp()
      Retrieves this epoch's timestamp
      byte[][] getWrite()
      Retrieves all WRITE value from all replicas
      byte[] getWrite​(int acceptor)
      Retrives the WRITE value from the specified replica
      boolean isAcceptCreated()
      Indicates if the consensus instance already created its ACCEPT message
      boolean isAcceptSent()
      Indicates if the consensus instance already sent its ACCEPT message
      boolean isAcceptSetted​(int acceptor)
      Informs if there is a accepted value from a replica
      boolean isRemoved()
      Informs if this epoch was removed from its consensus instance
      boolean isWriteSent()
      Indicates if the consensus instance already sent its WRITE message
      boolean isWriteSetted​(int acceptor)
      Informs if there is a WRITE value from a replica
      void setAccept​(int acceptor, byte[] value)
      Sets the accepted value from the specified replica
      void setAcceptMsg​(ConsensusMessage acceptMsg)
      Set the speculative ACCEPT message
      void setProof​(java.util.HashSet<ConsensusMessage> proof)  
      void setRemoved()
      Set this epoch as removed from its consensus instance
      void setWrite​(int acceptor, byte[] value)
      Sets the WRITE value from the specified replica
      java.lang.String toString()
      Print epoch information.
      void writeSent()
      Indicate that the consensus instance already sent its WRITE message
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • propValue

        public byte[] propValue
      • deserializedPropValue

        public TOMMessage[] deserializedPropValue
      • propValueHash

        public byte[] propValueHash
      • decisionRequested

        public boolean decisionRequested
    • Constructor Detail

      • Epoch

        public Epoch​(ServerViewController controller,
                     Consensus parent,
                     int timestamp)
        Creates a new instance of Epoch for acceptors
        Parameters:
        controller -
        parent - Consensus to which this epoch belongs
        timestamp - Timestamp of the epoch
    • Method Detail

      • setRemoved

        public void setRemoved()
        Set this epoch as removed from its consensus instance
      • isRemoved

        public boolean isRemoved()
        Informs if this epoch was removed from its consensus instance
        Returns:
        True if it is removed, false otherwise
      • setProof

        public void setProof​(java.util.HashSet<ConsensusMessage> proof)
      • getTimestamp

        public int getTimestamp()
        Retrieves this epoch's timestamp
        Returns:
        This epoch's timestamp
      • getConsensus

        public Consensus getConsensus()
        Retrieves this epoch's consensus
        Returns:
        This epoch's consensus
      • isWriteSetted

        public boolean isWriteSetted​(int acceptor)
        Informs if there is a WRITE value from a replica
        Parameters:
        acceptor - The replica ID
        Returns:
        True if there is a WRITE value from a replica, false otherwise
      • isAcceptSetted

        public boolean isAcceptSetted​(int acceptor)
        Informs if there is a accepted value from a replica
        Parameters:
        acceptor - The replica ID
        Returns:
        True if there is a accepted value from a replica, false otherwise
      • getWrite

        public byte[] getWrite​(int acceptor)
        Retrives the WRITE value from the specified replica
        Parameters:
        acceptor - The replica ID
        Returns:
        The value from the specified replica
      • getWrite

        public byte[][] getWrite()
        Retrieves all WRITE value from all replicas
        Returns:
        The values from all replicas
      • setWrite

        public void setWrite​(int acceptor,
                             byte[] value)
        Sets the WRITE value from the specified replica
        Parameters:
        acceptor - The replica ID
        value - The valuefrom the specified replica
      • getAccept

        public byte[] getAccept​(int acceptor)
        Retrieves the accepted value from the specified replica
        Parameters:
        acceptor - The replica ID
        Returns:
        The value accepted from the specified replica
      • getAccept

        public byte[][] getAccept()
        Retrieves all accepted values from all replicas
        Returns:
        The values accepted from all replicas
      • setAccept

        public void setAccept​(int acceptor,
                              byte[] value)
        Sets the accepted value from the specified replica
        Parameters:
        acceptor - The replica ID
        value - The value accepted from the specified replica
      • countWrite

        public int countWrite​(byte[] value)
        Retrieves the amount of replicas from which this process received a WRITE value
        Parameters:
        value - The value in question
        Returns:
        Amount of replicas from which this process received the specified value
      • countAccept

        public int countAccept​(byte[] value)
        Retrieves the amount of replicas from which this process accepted a specified value
        Parameters:
        value - The value in question
        Returns:
        Amount of replicas from which this process accepted the specified value
      • countAcceptFrom

        public int[] countAcceptFrom​(byte[] value)
        Retrieves th replicas from which this process accepted a specified value
        Parameters:
        value - The value in question
        Returns:
        replicas from which this process accepted the specified value
      • writeSent

        public void writeSent()
        Indicate that the consensus instance already sent its WRITE message
      • acceptSent

        public void acceptSent()
        Indicate that the consensus instance already sent its ACCEPT message
      • acceptCreated

        public void acceptCreated()
        Indicate that the consensus instance already created its ACCEPT message
      • isWriteSent

        public boolean isWriteSent()
        Indicates if the consensus instance already sent its WRITE message
        Returns:
        true if WRITE was indicated as sent, false otherwise
      • isAcceptSent

        public boolean isAcceptSent()
        Indicates if the consensus instance already sent its ACCEPT message
        Returns:
        true if ACCEPT was indicated as sent, false otherwise
      • isAcceptCreated

        public boolean isAcceptCreated()
        Indicates if the consensus instance already created its ACCEPT message
        Returns:
        true if ACCEPT was indicated as created, false otherwise
      • setAcceptMsg

        public void setAcceptMsg​(ConsensusMessage acceptMsg)
        Set the speculative ACCEPT message
        Parameters:
        acceptMsg - The speculative ACCEPT message
      • fetchAccept

        public ConsensusMessage fetchAccept()
        Fetch the speculative ACCEPT message. This method blocks until such message is set with setAcceptMsg(...);
        Returns:
        The speculative ACCEPT message
      • toString

        public java.lang.String toString()
        Print epoch information.
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • clear

        public void clear()
        Clear all epoch info.