Class CSNGenerator


  • public final class CSNGenerator
    extends Object
    This class defines a structure that is used for storing the last CSNs generated on this server or received from other servers and generating new CSNs that are guaranteed to be larger than all the previously seen or generated CSNs.
    • Method Detail

      • newCSNGenerator

        public static CSNGenerator newCSNGenerator​(ReplicaId replicaId,
                                                   long timestamp)
        Create a new CSNGenerator.
        Parameters:
        replicaId - id to use when creating CSNs.
        timestamp - time to start with.
        Returns:
        the new CSNGenerator
      • newCSNGenerator

        public static CSNGenerator newCSNGenerator​(ReplicaId replicaId,
                                                   ServerState state)
        Create a new CSNGenerator.
        Parameters:
        replicaId - replicaId to use when creating CSNs.
        state - This generator will be created in a way that makes sure that all CSNs generated will be larger than all the CSNs currently in state.
        Returns:
        the new CSNGenerator
      • newCSN

        public CSN newCSN()
        Generate a new CSN.
        Returns:
        the generated CSN
      • adjust

        public void adjust​(ServerState state)
        Adjust utility method that takes ServerState as a parameter.
        Parameters:
        state - the ServerState to adjust with
      • adjust

        public void adjust​(CSN csn)
        Adjust the lastTime of this CSNGenerator with a CSN that we have received from another server.

        This is necessary because we need that the CSN generated after processing an update received from other hosts to be as close as possible to the received CSN in order to have a global ordering that is close to wall-clock time.

        Parameters:
        csn - the CSN to adjust with