Class DefaultTimestampStrategy

  • All Implemented Interfaces:
    TimestampStrategy

    public final class DefaultTimestampStrategy
    extends Object
    implements TimestampStrategy
    Strategy that provides the current timestamp. This is an implementation of TimestampStrategy that provides millisecond resolution. The timestamp resolution is simulated by adding the next value of a counter that is incremented at every call to the method TimestampStrategy.getTimestamp(). The counter's range is from 0 to 9,999, that is, the number of 100-nanosecond intervals per millisecond. The counter is initialized with a random number between 0 and 255 to void duplicates in the case of multiple time-based generators running in parallel. ### RFC-4122 - 4.2.1.2. System Clock Resolution (4a) A high resolution timestamp can be simulated by keeping a count of the number of UUIDs that have been generated with the same value of the system time, and using it to construct the low order bits of the timestamp. The count will range between zero and the number of 100-nanosecond intervals per system time interval. ### RFC-4122 - 4.2.1.2. System Clock Resolution (3b) If a system overruns the generator by requesting too many UUIDs within a single system time interval, the UUID service MUST either return an error, or stall the UUID generator until the system clock catches up.
    • Constructor Detail

      • DefaultTimestampStrategy

        public DefaultTimestampStrategy()
    • Method Detail

      • getNextCounter

        protected long getNextCounter​(long timestamp)
        Get the next counter value.
        Parameters:
        timestamp - a timestamp
        Returns:
        the next counter value
        Throws:
        UuidCreatorException - an overrun exception if more than 10 thousand UUIDs are requested within the same millisecond