Class CsnFactory

    • Field Detail

      • lastTimestamp

        private static volatile long lastTimestamp
        The last timestamp
      • changeCount

        private int changeCount
        The integer used to disambiguate CSN generated at the same time
      • replicaId

        private int replicaId
        The replicaId to use for every CSN created by this factory
      • PURGE_INSTANCEID

        private static final int PURGE_INSTANCEID
        A special instance ID for a purge CSN
        See Also:
        Constant Field Values
      • lock

        private Object lock
        A lock used during the instance creation
    • Constructor Detail

      • CsnFactory

        public CsnFactory​(int replicaId)
        Creates a new CsnFactory instance
        Parameters:
        replicaId - The replica ID
    • Method Detail

      • newInstance

        public Csn newInstance()
        Returns a new Csn. Generated CSN can be duplicate if user generates CSNs more than 2G times a milliseconds.
        Returns:
        The new generated CSN
      • newInstance

        public Csn newInstance​(long timestamp,
                               int changeCount)
        Returns a new Csn created from the given values. This method is not to be used except for test purposes.
        Parameters:
        timestamp - The timestamp to use
        changeCount - The change count to use
        Returns:
        The new generated CSN
      • newPurgeCsn

        public Csn newPurgeCsn​(long expirationDate)
        Generates a CSN used to purge data. Its replicaID is not associated to a server.
        Parameters:
        expirationDate - The time up to the first CSN we want to keep
        Returns:
        The new generated CSN
      • setReplicaId

        public void setReplicaId​(int replicaId)
        Sets the replica ID
        Parameters:
        replicaId - The replica ID