- All Implemented Interfaces:
- ClockSequenceStrategy, Sequence
public class DefaultClockSequenceStrategy
extends AbstractSequence
implements ClockSequenceStrategy
This class is an implementation of the 'clock sequence' of the RFC-4122. The
maximum value of this sequence is 16,383 or 0x3fff.
### RFC-4122 - 4.1.5. Clock Sequence
(1) For UUID version 1, the clock sequence is used to help avoid duplicates
that could arise when the clock is set backwards in time or if the node ID
changes.
(2) If the clock is set backwards, or might have been set backwards (e.g.,
while the system was powered off), and the UUID generator can not be sure
that no UUIDs were generated with timestamps larger than the value to which
the clock was set, then the clock sequence has to be changed. If the previous
value of the clock sequence is known, it can just be incremented; otherwise
it should be set to a random or high-quality pseudo-random value.
(3) Similarly, if the node ID changes (e.g., because a network card has been
moved between machines), setting the clock sequence to a random number
minimizes the probability of a duplicate due to slight differences in the
clock settings of the machines. If the value of clock sequence associated
with the changed node ID were known, then the clock sequence could just be
incremented, but that is unlikely.
(4) The clock sequence MUST be originally (i.e., once in the lifetime of a
system) initialized to a random number to minimize the correlation across
systems. This provides maximum protection against node identifiers that may
move or switch from system to system rapidly. The initial value MUST NOT be
correlated to the node identifier.